Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response not a valid JSON Object #255

Closed
johnseabird opened this issue Jan 17, 2020 · 8 comments
Closed

Response not a valid JSON Object #255

johnseabird opened this issue Jan 17, 2020 · 8 comments
Labels
enhancement New feature or request question Further information is requested
Projects

Comments

@johnseabird
Copy link

The response I get via VaRest from Twitter API is not a valid JSON object and can not be parsed.
Postman generates a valid JSON Object.

Compared both via https://jsonlint.com/

Here you have the invaild JSON file first and afterwards the same request made with postman.

### INVALID JSON FILE - ANSWER FROM TWITTER API with VARest

https://gist.github.com/johnseabird/460faff61a0b821c2ffc4a712d1c45aa

### VALID JSON FILE - ANSWER FROM TWITTER API with POSTMAN

https://gist.github.com/johnseabird/ac39633b3e3300f491463c36668dbac2

VARest Log From Unreal:

LogVaRest: Error: UVaRestJsonObject::SetRootObject(43): Trying to set invalid json object as root one. Reset now.
LogVaRest: Warning: JSON could not be decoded!

SCREENSHOTS

VARest_json_request_issue

@ufna ufna added the question Further information is requested label Jan 17, 2020
@ufna
Copy link
Owner

ufna commented Jan 17, 2020

Hi @johnseabird ,

top-level arrays currently not supported with VaRest (it'll be done with #245), but you can handle them like this: https://www.notion.so/ufna/HowTo-Read-top-level-arrays-5c6da7c25b044fb3b7de0c9e65d512f5

@johnseabird
Copy link
Author

Hi @johnseabird ,

top-level arrays currently not supported with VaRest (it'll be done with #245), but you can handle them like this: https://www.notion.so/ufna/HowTo-Read-top-level-arrays-5c6da7c25b044fb3b7de0c9e65d512f5

thanks for the quick reply. I think I'm not quite getting the solution in my case.
the format within the JSON file also seems destructed. Or I'm I getting the solution wrong?

just compared line 13:

invalid:

"source": "\u003ca href=\"https:\/\/mobile.twitter.com\" rel=\"nofollow\"\u003eTwitter Web App\u003c\/a

valid:

"source": "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>",

@ufna
Copy link
Owner

ufna commented Jan 17, 2020

It definitely will help you to read variables. For now you can't do it cause you have top-level array without name.

I'll check the encoding at Sunday.

@johnseabird
Copy link
Author

johnseabird commented Jan 17, 2020

It definitely will help you to read variables. For now you can't do it cause you have top-level array without name.

I'll check the encoding at Sunday.

thank you very much for the effort!
looking forward to that.

I think I'm kinda blocked in my head how this helps me to read the variables. sorry for that.
I still can't access them after wrapping it into an array with name...mhmm...

edit: getting it now -> but I compared the solution and it worked with the response from postman but not for VARest. the encoding / decoding seems to be the problem.

It seems that the encoding is destroying the rest of the json file. quoation marks are not where they should be / objects do not get closed correctly.

have a good weekend and thanks!

edit: just a quick headsup. I get the same formatting / encoding problem with the c++ version. Deserialize does not finish successful. If I have a look at the Result as a String, I have the same problems.

I already post processed and fixed some of the issues within blueprints.
but in general, the response seems to have shifted quotations marks / does mess up the line breaks.

image

So I kinda fixed to formatting issue for one request. Now I'm dealing with having multiple root elements. the fix for the line break / paragraph break is the following:

image

this replaces line strange formatting issues (html element stuff <>) as well as the breaks.
to fix the breaks, I replace the COMMA QUOTATION MARK with COMMA LINEBREAK QUOTATION MARK

@ufna ufna added this to In progress in Development Jan 22, 2020
@johnseabird
Copy link
Author

johnseabird commented Jan 22, 2020

Please have a look at some solved problems above.
It still might be cool to have it implemented if you find the time.

After having a processed clean JSON Object, with accessible fields, I started to request multiple tweets from the Twitter API. The response contains multiple JSON Root Elements (one per Tweet) which make the JSON invalid.

Is there any way to handle this?

image

You can check the gist

https://gist.github.com/johnseabird/76b8e54ed6403ac12265170d5c4bbebd

edit: If you want to, I can open a new issue for that one.

@ufna ufna closed this as completed in 22237e4 Jan 28, 2020
Development automation moved this from In progress to Done Jan 28, 2020
@ufna ufna added the enhancement New feature or request label Jan 28, 2020
@ufna
Copy link
Owner

ufna commented Jan 28, 2020

u-chars fixed in latest develop

@jonny2027
Copy link

Could you tell me what was the fix so I can confirm I have it as I am also getting this issue from the 4.24 version but I have downloaded the develop branch and compared the differences and dont notice anything

@ufna
Copy link
Owner

ufna commented Apr 30, 2020

@jonny2027 , please check that you have bUseChunkedParser = false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
Development
  
Done
Development

No branches or pull requests

3 participants