Questions tagged [stringify]

A function that converts a JavaScript value to a JavaScript Object Notation (JSON) string.

A common use of JSON is to exchange data to/from a web server. When sending data to a web server, the data has to be a "string". Convert a JavaScript object into a string with JSON.stringify().

JSON.stringify() documentation.

718 questions
34
votes
8 answers

Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse ()

I need some help with this error: Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse () at Object.success (dashboard.js:22) at fire (jquery-3.3.1.js:3268) at Object.fireWith [as resolveWith] (jquery-3.3.1.js:3398) at done…
Ameur Baccoucha
  • 559
  • 1
  • 8
  • 17
34
votes
3 answers

Why does JSON.stringify return empty object notation "{}" for an object that seems to have properties?

The following example shows that JSON.stringify() returns the string "{}" for SpeechSynthesisVoice objects: var voiceObject = window.speechSynthesis.getVoices()[0]; JSON.stringify(voiceObject); //returns "{}"? Complete example: JSFiddle Why does…
Chilly Code
  • 678
  • 2
  • 6
  • 17
30
votes
3 answers

JSON.stringify in java - android

Is there any way to perform a JSON.stringify in android? I keep seeing JSON.stringify(JSONObject) all around the web, but I cant find the JSON class in android. Any help?
בועז יערי
  • 445
  • 1
  • 5
  • 14
29
votes
4 answers

JSON.stringify is ignoring object properties

See the jsfiddle example http://jsfiddle.net/frigon/H6ssq/ For some reason there are fields that JSON.stringify is ignoring. Is there a way to force JSON.stringify to parse them? As the jsfiddle shows... this code...
frigon
  • 4,979
  • 7
  • 32
  • 38
28
votes
10 answers

Json - stringify so that arrays are on one line

Is it possible to stringify a JSON object to look like this, with arrays in one line - not indented { "Repeat": { "Name": [["Top_level","All"],[[1,1]]], "Link": [["Top_level"],[[1,1]]] }, "Delete": ["Confirm","Cancel"], …
Chris Glasier
  • 791
  • 2
  • 10
  • 21
28
votes
4 answers

JSON.stringify converting Infinity to null

I have JavaScript Object say: var a = {b: Infinity, c: 10}; When I do var b = JSON.stringify(a); it returns the following b = "{"b":null, "c":10}"; How is the JSON.stringify converts the object to strings? I tried MDN Solution. function…
me_digvijay
  • 5,374
  • 9
  • 46
  • 83
26
votes
3 answers

Space in between JSON.stringify output

I am using Jquery to get all products name from page and than put it on array. I am using this code