GO Online Toolset
home
search
feedback
【the waiter】announcement:

Yaml to json
2200  |   |   |  13

Function introduction

  1. Online yaml transfer to json
  2. Explanation: Since the child nodes of the yaml tree are stored in map during the conversion process, the order of the results obtained after conversion to json is out of order.

Example

apiVersion: v1
kind: Service
metadata:
  name: test-k8s
spec:
  selector:
    app: test-k8s
  type: ClusterIP
  ports:
    - port: 8080        
      targetPort: 8080

after treatment

{
    "apiVersion": "v1",
    "kind": "Service",
    "metadata": {
        "name": "test-k8s"
    },
    "spec": {
        "ports": [
            {
                "port": 8080,
                "targetPort": 8080
            }
        ],
        "selector": {
            "app": "test-k8s"
        },
        "type": "ClusterIP"
    }
}