ijavascript icon indicating copy to clipboard operation
ijavascript copied to clipboard

JSON.stringify() wraps the output within ` (Grave Accent mark)

Open ASHIQUEMD opened this issue 6 months ago • 1 comments

Issue: if the object contains string data with single quoted value in it, e.g. "Test 'data'", JSON.stringify(results) returns result wrapped in ` (Grave Accent mark).

Actual result:

image

Expected result (without ` ): {"analyzer":"Test 'data'","details":{"range":{"start":"1","end":"2"},"description":"Hello"}}

Sample code:

function main() {
    const results = {
        analyzer: "Test 'data'",
        details: {
            range: {
                start: "1",
                end: "2"
            },
            description: "Hello"
        }
      };

    return JSON.stringify(results);
  }
  
 main();

ASHIQUEMD avatar Jul 29 '24 13:07 ASHIQUEMD