Skip to content
New issue

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

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

Already on GitHub? # to your account

pretty json function not working correctly on certain sites #272

Open
jasan-s opened this issue Aug 27, 2017 · 6 comments
Open

pretty json function not working correctly on certain sites #272

jasan-s opened this issue Aug 27, 2017 · 6 comments

Comments

@jasan-s
Copy link

jasan-s commented Aug 27, 2017

results look like this while using on some sites:
artoo.saveJson(list, {filename: "test.json", pretty: true});

"[{\"cartoon\": \"\", \"name\": \"Wonder Woman\"]"

On some sites it works fine and saves it like so:

[
  {
  "cartoon" : "",
  "name": "Wonder Woman" 
  }
]

@Yomguithereal
Copy link
Member

If you use saveJson it should produce a normal non-prettified line. You would rather use savePrettyJson to get a nicer output.

However, I don't really get why some sites would have a different behavior here because it really just uses the engines 'JSON.stringify` function which does not have a different behavior on different sites. Can you pinpoint me to some sites where the behavior you see can be replicated so I can investigate?

@jasan-s
Copy link
Author

jasan-s commented Aug 27, 2017

sure: trailers is one of these site.

my current workaround is the following:

var querystring = require('querystring');
var list = require('test.json')
var newList= querystring.unescape(list);

@Yomguithereal
Copy link
Member

Are you doing this in the browser? Or in node through puppeteer?

@jasan-s
Copy link
Author

jasan-s commented Aug 27, 2017

chrome browser, through dev console

@jasan-s
Copy link
Author

jasan-s commented Aug 27, 2017

it seems like somewhere an extra JSON.stringify() is happening

@Yomguithereal
Copy link
Member

I can't reproduce your issue. If I do the following:

var o = {hello: 'world'};
artoo.savePrettyJson(o);

I get the expected result.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants