We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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)) }
{ "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" } } } ] } } } } }
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
The text was updated successfully, but these errors were encountered:
are you saying that the cpu and memory strings in orginal json are now empty in yaml?
cpu
memory
Sorry, something went wrong.
Merge pull request ghodss#32 from BenTheElder/bump-dep
5f5be1e
upgrade gopkg.in/yaml.v2 to v2.2.8
No branches or pull requests
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
The text was updated successfully, but these errors were encountered: