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

JSON Stringify indentation not working #10995

Closed
adi518 opened this issue Jan 25, 2017 · 7 comments
Closed

JSON Stringify indentation not working #10995

adi518 opened this issue Jan 25, 2017 · 7 comments
Labels
question Issues that look for answers.

Comments

@adi518
Copy link

adi518 commented Jan 25, 2017

  • Version: 7.4.0
  • Platform: Windows (64-bit)

It appears this doesn't work anymore:

JSON.stringify({name: 'test'}, null, 4)

Output stays minified.

@vsemozhetbyt
Copy link
Contributor

If you try this simple evaluation in REPL, you will get a 'debug` output. Try this:

console.log(JSON.stringify({name: 'test'}, null, 4));

@mscdex
Copy link
Contributor

mscdex commented Jan 25, 2017

It works for me:

> JSON.stringify({name: 'test'}, null, 4)
'{\n    "name": "test"\n}'
> console.log(JSON.stringify({name: 'test'}, null, 4))
{
    "name": "test"
}
undefined
> 

Is that what you're seeing @adi518 ?

@mscdex mscdex added the question Issues that look for answers. label Jan 25, 2017
@osmanmesutozcan
Copy link

Here also works:

> JSON.stringify({name: 'test'}, null, 4)
'{\n    "name": "test"\n}'
> console.log(JSON.stringify({name: 'test'}, null, 4))
{
    "name": "test"
}
undefined
>

Platform: macOS.

@adi518
Copy link
Author

adi518 commented Jan 26, 2017

Nope, still doesn't work whatsoever. It used to work just fine some months ago.

@vsemozhetbyt
Copy link
Contributor

@adi518 Could you please describe in detail how do you launch the code and what output you get literally?

@Fishrock123
Copy link
Member

@adi518 can you try it in the REPL? (Launch node without a file)

@adi518
Copy link
Author

adi518 commented Jan 26, 2017

Ok, found the culprit. I had a JSON.stringify polyfill that messed it up. So sorry.

@adi518 adi518 closed this as completed Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

5 participants