ijson fails with trailing garbage parse error - parse-error

for prefix, event, value in parser:
print(prefix)
I get the following error after executing the above code , I dont understand what the error is.
ijson.common.IncompleteJSONError: parse error: trailing garbage
nt":19485,"verified":false}} {"user_id":1408970940,"id":4496
(right here) ------^

Seems you are trying to parse a JSON document with more than one top-level object, which is not standard. ijson allows for this though if you give the multiple_values=True flag to the method you are using.

Related

parcel2 error with valid JSON: "#parcel/transformer-json:" JSON5: invalid end of input at 1:1

Not sure why I'm getting this error -- I'm using default configuration specs for parcel2, so it should work out of the box according to the documentation.
I've validated the JSON object and it seems to be valid, so this is a bit of a head scratcher.
None of the config/rc files are incorrectly formatted or empty, either.
It appears as though this was a bit of a silly error -- while the JSON object was valid, the JSON file needed a carriage return (enter at the end of the file) in order to be read correctly by the parcel transformer.

Invalid JSON syntax error in configuration file on homebridge

{
"bridge":{
"name":"Homebridge F8F5",
"username":"0E:8F:12:8D:F8:F5",
"port":51739,
"pin":"670-48-238"
},
"accessories":[
],
"platforms":[
{
"name":"Config",
"port":8581,
"platform":"config"
}
]
}{
"accessories":[
{
"name":"Roku",
"accessory":"Roku",
"ip":"http://10.204.1.238:8060",
}
I am getting an error when I try to run this config file in homebridge. What am I doing wrong? When I try to submit it through the web interface it will not allow me to and says “Config JSON error: invalid json syntax” Any help will be welcome! I have tried to put it through an online json error finder and it narrowed it down to this snippet.
Ummm... looks like you tried to edit this file without knowing the basic concepts of JSON.
Start by reading JSON - Introduction on W2Schools.com
Also, if you're not sure, use an online JSON validator. Use your fav. search engine to look for "JSON cleaner". (I use JSON Formatter & Validator at Curious Concept.)
Off the bat I can see a few issues with the JSON you provided.
the "}{" string ... what's that for? JSON cannot parse that ... either add "," between (if you wanted a new set) or (in this case) remove it.
you have two "accessories". JSON usually get parsed into an object or array ... one cannot have duplicates on the ket names. (In this case) remove the first one.
the second "accessories" array (denoted by "[") has no end (no "]")
the whole set (started with "{") has no end (no "}")

What is the "correct" way to format json from SQL Server?

I have a stored proc that returns json. The proc works fine and when I call it in SSMS it returns a json object that I can click and see as valid json. When I call it through Visual Studio it does the same, and clicking into it and pressing return formats it nicely so it's readable (and not all on a single line). If I take the string and pass it back into the sql function IsJson, it also returns true, so I'm 100% confident that the json coming out of the proc is valid.
However, my frontend developer is unable to parse it, and it seems to boil down to something trying to convert it somewhere.
The json (as output from the proc) is:
{"APIResult":[{"ID":200,"Status_Message":"Success","Developer_Message":"Successful login for D56D10AC-3A74-42FC-8BB5-F783A6C0C556 33E4F907-F1E5-4F1B-8CA5-5521291E683A (AppID: (null)).","User_Message":"Successful login","User":[{"ID":"D56D10AC-3A74-42FC-8BB5-F783A6C0C556"}]}]}
Using Postman to hit the live API (or localhost) I get back the data I expect (as above) however, it wraps the entire thing in double quotes and escapes all the double quotes around each element, so I get:
"{\"APIResult\":[{\"ID\":200,\"Status_Message\":\"Success\",\"Developer_Message\":\"Successful login for D56D10AC-3A74-42FC-8BB5-F783A6C0C556 33E4F907-F1E5-4F1B-8CA5-5521291E683A (AppID: (null)).\",\"User_Message\":\"Successful login\",\"User\":[{\"ID\":\"D56D10AC-3A74-42FC-8BB5-F783A6C0C556\"}]}]}"
When I try to parse this in sql (using isjson) it returns false. However, parsing this same code though jsonlint.com interprets it as valid. Trying it through the parser my developer is using http://json.parser.online.fr throws it out as errors too.
At a push, I can tell my developer to strip the first and last characters and replace every \" with " but this seems a bit faffy.
Are there different interpretations of json? I've read that this is often caused by the calling app expecting a string that it needs to json-ify and because it's getting a json object it's json-ifying the json, but even if I force sql server to output the string as a string and not json, it still seems the same. SQL is definitely pushing it out correctly but whatever my developer is calling the api through returns the same format as postman, and doesn't like it. How can I ensure that what the calling code gets is what SQL is giving and not some weird interpretation?
#Tim Try to deserialize the output of stored procedure. Use JSonConvert.Derialize in C#

How to know what is wrong in a JSON object?

I am trying to send the following JSON object and I get the error shown below,I checked #http://jsonviewer.stack.hu ,the JSON format seems to be correct,what am I missing and how to fix this?
{"component":{"name":"Company tech (New Bugs)", "version":"B"},"assignee":1234456,"milestone":"chiHW","priority":2,"state":"Analyze","substate":"Nominate","title":"[please ignore]CS\:4355C1\,4364B2\:WDI\:DHD\:HLK\(16299\)\-\>\"DF\ \-\ Sleep\ Tests\"\-\>Assert\-\>bcmpciedhd63\.sys\(dhd\_os\_ioctl\_resp\_wait\)\-\>dhd\_ndis\.c\#4449"}
Error:-
{"message":"An invalid JSON Object was passed in the request body. Please pass a valid JSON object.","help":"View documentation at http://bugs.company.com/","title":"Invalid Request","status":"400 Bad Request"}
You could have pasted your expression into https://jsonlint.com. It tells you where the problem is, and you can experiment until the JSON is no longer invalid. In your case, the problem is those backslashes in the last dictionary value (the one that starts "please ignore").
You could use jq to get a more specific parse error
watson:~$ cat >j
{"component":{"name":"Company tech (New Bugs)", "version":"B"},"assignee":1234456,"milestone":"chiHW","priority":2,"state":"Analyze","substate":"Nominate","title":"[please ignore]CS\:4355C1\,4364B2\:WDI\:DHD\:HLK\(16299\)\-\>\"DF\ \-\ Sleep\ Tests\"\-\>Assert\-\>bcmpciedhd63\.sys\(dhd\_os\_ioctl\_resp\_wait\)\-\>dhd\_ndis\.c\#4449"}
^D
watson:~$ jq <j
parse error: Invalid escape at line 1, column 333

Getting error while converting json file to a data frame using jsonlite

I am using the tweetscores package of R to get 'tweets list from twitter. The tweets are stored in json format. While converting it to a data frame I get a lexical error
' Error: lexical error: inside a string, '\' occurs before a character which it may not.".
Any solution to the mentioned error.
A part of the json file text
":[{"text":["MUFC"],"indices":[[83],[88]]}],"symbols":[],"user_mentions":[],"urls":[]},"metadata":{"iso_language_code":["en"],"result_type":["recent"]},"source":["http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>"],"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":[7.32108114527322e+017],"id_str":["732108114527322112"],"name":["wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww(^o^)/"],"screen_name":["SukiSukinal"],"location":["+6222"],"description":["Alliansi osaosi ngevote kagak. katanya sih fans a.k.a + "],"url":null,"entities":{"description":{"urls":[]}},"protected":[false],"followers_count":[163],"friends_count":[107],"listed_count":[4],"created_at":["Mon May 16 07:19:11 +0000
Json format does not allow backslashes so you need to escape them. replace any '\' character found with '\\'. Refer [here][1]
[1]: http://www.json.org/ for more info
You likely have an incomplete json string, which may be caused by the package or by an interrupted connection to Twitter's API. A complete json string returned from Twitter should look something like the following:
which I got using rtweet's stream_tweets() function. With a complete string returned by Twitter's REST or stream API, you should be able to convert the data using basically any json parser (e.g., jsonlite::fromJSON()).