2017-02-23 89 views
-4

我有JSON字符串我想验证它我使用在线JSON格式的错误显示请帮助我“:错误:解析第1行的错误: {节点:{创建 ----^ 期待“STRING”,“}”,得到了“未定义” 的json:”如何写正确的JSON格式

{ 
    nodes: { 
     Creation: { 
      color: 'red', 
      shape: 'dot', 
      x: 0.4, 
      y: 0, 
      fixed: true, 
      alpha: 1 
     }, 
     Send_To_Modification: { 
      color: CLR.branch, 
      shape: 'dot', 
      x: 0.4, 
      y: 0, 
      fixed: true, 
      alpha: 1 
     }, 
     Send_To_Verification: { 
      color: CLR.branch, 
      shape: 'dot', 
      x: 0.4, 
      y: 0, 
      fixed: true, 
      alpha: 1 
     }, 
     IBAN checking: { 
      color: CLR.branch, 
      shape: 'dot', 
      x: 0.4, 
      y: 0, 
      fixed: true, 
      alpha: 1 
     }, 
     Send_To_Kassip(KWD SAA Down): { 
      color: CLR.branch, 
      shape: 'dot', 
      x: 0.4, 
      y: 0, 
      fixed: true, 
      alpha: 1 
     } 
    }, 
    edges: { 
     Creation: { 
      Send_To_Modification: { 
       length: 001 
      }, 
      Send_To_Verification: { 
       length: 001 
      }, 
      IBAN checking: { 
       length: 001 
      }, 
      Send_To_Kassip(KWD SAA Down): { 
       length: 001 
      } 
     } 
    } 
}` 
+2

这不是JSON,而是一个JS对象。 – evolutionxbox

+0

您可以使用任何JSON formater在线获得您的答案,而不是在这里问。 –

+0

虽然网站http://json.org不是最新的,它可以帮助你创建一个json对象。 – reporter

回答

1

在JSON,钥匙必须是字符串,用双引号和字符串值写入也必须用双引号写入。

{ 
"nodes": { 
    "Creation": { 
     "color": "red", 
     "shape": "dot", 
     "x": 0.4, 
     "y": 0, 
     "fixed": true, 
     "alpha": 1 
    }, 
    "Send_To_Modification": { 
     "color": "CLR.branch", 
     "shape": "dot", 
     "x": 0.4, 
     "y": 0, 
     "fixed": true, 
     "alpha": 1 
    }, 
    "Send_To_Verification": { 
     "color": "CLR.branch", 
     "shape": "dot", 
     "x": 0.4, 
     "y": 0, 
     "fixed": true, 
     "alpha": 1 
    }, 
    "IBAN checking": { 
     "color": "CLR.branch", 
     "shape": "dot", 
     "x": 0.4, 
     "y": 0, 
     "fixed": true, 
     "alpha": 1 
    }, 
    "Send_To_Kassip(KWD SAA Down)": { 
     "color": "CLR.branch", 
     "shape": "dot", 
     "x": 0.4, 
     "y": 0, 
     "fixed": true, 
     "alpha": 1 
    } 
}, 
"edges": { 
    "Creation": { 
     "Send_To_Modification": { 
      "length": "001" 
     }, 
     "Send_To_Verification": { 
      "length": "001" 
     }, 
     "IBAN checking": { 
      "length": "001" 
     }, 
     "Send_To_Kassip(KWD SAA Down)": { 
      "length": "001" 
     } 
     } 
    } 
}