5

Python 2.6.6 和我所做的就是从 zmq 和 json.loads(message) 接收消息。对不起,因为它是 json 的所有混乱

{"mouhter_id":"one_keert","header":{"header_version":"1","message_type":"one_keert","session_id":"428c0ebd497b9dfcc3170da0d1e0628e","timestamp":1376616699,"src_path":"*/dc/occ1/bell000/lcd_one_mtmt/26866","dst_path":"*/dc/lkjhgvd/lkjhgvd/fegtault/24068"},"payload":{"destHardwareId":"","command":{"id":"bmclmc1","params":{"keylen":"396","key":"AAAAIM0XlJxAEiX6t1KSyuQh+gCnP1Jmu3lkTZvxhiOUogyMAAABDC0tLS0tQkVHSU4gUFVCTElDIEtFWS0tLS0tCk1JR2JNQkFHQnlxR1NNNDlBZ0VHQlN1QkJBQWpBNEdHQUFRQjAxaTZkOG5xVTBnQVBIdHhFMDZqNEI0UDF4TXoKVTVYYy83RnZCVzBtTFI3WlQxRTRxUmw3VEx0OVcwSi85OU5XRzF3NU14Um1oK2dubEJxTTFkNytadU1BNU1NdgpFbmNHcmFpNU1UcHo3elE0cm9CQWZFOVA0czFvM0dRaThSRlVSbFJMdWl2Ym1jempkcVdCYVlEUjNCUU9IOU96ClRWOHFhUnpCN3l0T1NnS09yZzA9Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQoAAABAg7od/LedQJ8MEBvKQjcBWM2ObdIeSDd/2VygDn0XFwBgUpYiWgum7FE8O51E0Xv3/R6ibvgSPFblqHqLDBNzOgAAAAAAAAAAAAAAAAAAAAAAAAAA"}}}}

我有以下 JSON 并且在 python 中我正在尝试加载它以便我可以提取数据。

{
   "e_id": "1231231",
   "header": {
              "h_version": "1",
              "m_type": "abc",
              "s_id": "ffsfsd",
              "timestamp": 1376614509,
              "s_path": "*/dc/s1/De620/cpmgmt/25804",
              "d_path": "*/dc/sfer/sfer/kelt/23642"
              },
"payload": {
"dereId": "",
"cond":       {
              "id": "srcstg1",
              "pams": {
                     "keen": "396",
                     "ke":                               "AAAAICZJsxIYABq3JXFRJ7ouZtoLDOLIJBnrw03uASQTiK+nAAABDC0tLS0tQkVHSU4gUFVCTElDIEtFWS0tLS0tCk1JR2JNQkFHQnlxR1NNNDlBZ0VHQlN1QkJBQWpBNEdHQUFRQkR2SEZLNVZZdUg3ZUFMRitLeWhLbWl0TEdEMzAKZmJOakNHYkVNRW1Geld4cFgzZXJ0RjhKSjdjMWZ6cFRhekJGRkpDNW5vR3FycWl2M3VGbGNuMitjUUlCUC9LaQo4V0h4ZVNBVkQ3R2lNTXJHMEVGYTBrOWNucnd5MEtWeU93MEVYcmwyQUNJcXg5enZBV3NLeERhUjRlRzRZVi9jCjB2cVlKcEh1OXNMbE9jWDJJVW89Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQoAAABA+T4YOvY1ynTIlAUn8xI+/0c+2EAPRFF1uHx8jBP7uuNkb/wnRZl0hJWx6NAOd0kHuh2RdIXXMhXChaEWRNxq6wAAAAAAAAAAAAAAAAAAAAAAAAAA"
                     }
               }
           }
}

它向我抛出以下错误:

raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 1 column 904 - line 1 column 905 (char 904 - 905)

我已经使用 jsonlint 来检查文件的有效性,它似乎通过了验证。但是我仍然收到这个错误?已从字符串中删除了所有新行和制表符。这里有什么遗漏吗?

4

1 回答 1

1

我从 C++ 客户端获取的 json 字符串末尾有一个空字符,所以只需删除该空字符,现在一切正常。

于 2013-08-16T19:04:03.963 回答