1

my device will sent json data like this:

[{"channel":924125000, "sf":10, "time":"2017-05-11T16:56:15", "gwip":"192.168.1.125", "gwid":"00004c4978dbf5b4", "repeater":"00000000ffffffff", "systype":5, "rssi":-108.0, "snr":17.0, "snr_max":23.3, "snr_min":10.8, "macAddr":"00000000000000c3", "data":"4702483016331210179183", "frameCnt":1, "fport":2}]

but sometimes i received multiple json data(two or more):

[{"channel":924125000, "sf":10, "time":"2017-05-11T16:56:15", "gwip":"192.168.1.125", "gwid":"00001c497b48dbf5", "repeater":"00000000ffffffff", "systype":5, "rssi":-108.0, "snr":17.0, "snr_max":23.3, "snr_min":10.8, "macAddr":"00000000050100e8", "data":"4702483016331210179183", "frameCnt":1, "fport":2}],[{"channel":924125000, "sf":10, "time":"2017-05-11T16:56:15", "gwip":"192.168.1.125", "gwid":"00001c497b48dbf5", "repeater":"00000000ffffffff", "systype":5, "rssi":-108.0, "snr":17.0, "snr_max":23.3, "snr_min":10.8, "macAddr":"00000000050100e8", "data":"4702483016331210179183", "frameCnt":1, "fport":2}]

when i parse multiple json data

json_Dict = json.loads(jsonData)

then

File "/usr/lib/python2.7/json/decoder.py", line 369, in decode raise ValueError(errmsg("Extra data", s, end, len(s))) ValueError: Extra data: line 1 column 303 - line 1 column 1818 (char 302 - 1817)

how can parse every multiple json data ?

thanks for your help

2 Answers 2

1

because you have multiple objects in your json you should include them in a list :

json_List = json.loads('[' + jsonData + ']')
Sign up to request clarification or add additional context in comments.

Comments

0

Paste it in a Tool like JSONLINT

and you get:

Error: Parse error on line 17: ...": 1, "fport": 2}], [{ "channel": 924 ---------------------^ Expecting 'EOF', got ','

which is the cause of your error. This is not valid JSON. The correct structure would be something like [[...],[...]]. You have [...],[...], which is not correct.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.