GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JSON Stringify indentation not working · Issue #10995 · nodejs/node

JSON Stringify indentation not working #10995

New issue
Copy link
New issue
Copy link
Closed
Closed
JSON Stringify indentation not working#10995
Copy link
Labels
questionIssues asking questions about Node.js.

Description

@adi-works
adi-works
opened on Jan 25, 2017
Issue body actions
  • Version: 7.4.0
  • Platform: Windows (64-bit)

It appears this doesn't work anymore:

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

Output stays minified.

Activity

  1. vsemozhetbyt commented on Jan 25, 2017

    @vsemozhetbyt
    vsemozhetbyt
    on Jan 25, 2017
    Contributor
    More actions

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

    console.log(JSON.stringify({name: 'test'}, null, 4));
  2. mscdex commented on Jan 25, 2017

    @mscdex
    mscdex
    on Jan 25, 2017
    Contributor
    More actions

    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 ?

  3. mscdex
    added
    questionIssues asking questions about Node.js.
    on Jan 25, 2017
  4. osmanmesutozcan commented on Jan 26, 2017

    @osmanmesutozcan
    osmanmesutozcan
    on Jan 26, 2017
    More actions

    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.

  5. adi-works commented on Jan 26, 2017

    @adi-works
    adi-works
    on Jan 26, 2017
    Author
    More actions

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

  6. vsemozhetbyt commented on Jan 26, 2017

    @vsemozhetbyt
    vsemozhetbyt
    on Jan 26, 2017
    Contributor
    More actions

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

  7. Fishrock123 commented on Jan 26, 2017

    @Fishrock123
    Fishrock123
    on Jan 26, 2017
    Contributor
    More actions

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

  8. adi-works commented on Jan 26, 2017

    @adi-works
    adi-works
    on Jan 26, 2017
    Author
    More actions

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

    Reacted by Vse Mozhe Buty and Osman Mesut OZCAN
  9. adi-works
    closed this as completedon Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues asking questions about Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.