TCL json2dict使用报错求助:官方示例执行失败及修正验证
TCL json2dict 报错“missing value to go with key”的解决办法
参考TCL json库官方示例编写代码时,执行以下代码会触发missing value to go with key错误:
package require json 1.3.3 set data [::json::json2dict { "Image": { "Width": 800, "Height": 600, "Title": "View from 15th Floor", "Thumbnail": { "Url": "http://www.example.com/image/481989943", "Height": 125, "Width": "100" }, "IDs": [116, 943, 234, 38793] } } ] dict get $data Image missing value to go with key dict keys $data missing value to go with key
解决办法
给传入::json::json2dict的JSON字符串外层额外添加一对大括号,修正后代码可正常运行:
set data [::json::json2dict {{ "Image": { "Width": 800, "Height": 600, "Title": "View from 15th Floor", "Thumbnail": { "Url": "http://www.example.com/image/481989943", "Height": 125, "Width": "100" }, "IDs": [116, 943, 234, 38793] } }} ]
内容的提问来源于stack exchange,提问作者Gert Gottschalk
相关产品推荐
相关产品推荐

