bug
wumingcheng opened this issue · 1 comments
I found a bug, when I test jsonToyaml. when value is a number, yaml.JSONToYAML() function will return "".
func Test_JsonToYaml(t *testing.T) {
var data = { "deployment": { "kind": "Deployment", "apiVersion": "extensions/v1beta1", "metadata": { "name": "app-0807-002", "annotations": { "cpu": "0.5", "memory": "256" }, "namespace": "030bb124aef6409daec0d026f21e8dea", "labels": { "app": "app-0807-002", "ns": "030bb124aef6409daec0d026f21e8dea" } }, "spec": { "replicas": 1, "selector": { "matchLabels": { "app": "app-0807-002", "ns": "030bb124aef6409daec0d026f21e8dea" } }, "template": { "metadata": { "labels": { "app": "app-0807-002", "ns": "030bb124aef6409daec0d026f21e8dea" } }, "spec": { "containers": [ { "image": "registry.paas/library/nginx:latest", "imagePullPolicy": "IfNotPresent", "name": "nginx", "resources": { "limits": { "cpu": "500m", "memory": "256Mi" } } } ] } } } } }
yaml, err := yaml.JSONToYAML([]byte(data))
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
fmt.Println(string(yaml))
}
response:
deployment:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
cpu: "0.5"
memory: "256"
labels:
app: app-0807-002
ns: 030bb124aef6409daec0d026f21e8dea
name: app-0807-002
namespace: 030bb124aef6409daec0d026f21e8dea
spec:
replicas: 1
selector:
matchLabels:
app: app-0807-002
ns: 030bb124aef6409daec0d026f21e8dea
template:
metadata:
labels:
app: app-0807-002
ns: 030bb124aef6409daec0d026f21e8dea
spec:
containers:
- image: registry.paas/library/nginx:latest
imagePullPolicy: IfNotPresent
name: nginx
resources:
limits:
cpu: 500m
memory: 256Mi
are you saying that the cpu
and memory
strings in orginal json are now empty in yaml?