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
-2
votes
2 answers

JSON data iteration

Am trying to call up an json api and iterate the result ,but getting error as Uncaught TypeError: Cannot use 'in' operator to search for '379741' in {"status":true,"flights":...} fiddle here http://jsfiddle.net/au8ahmho/1/ (function () { …
sajanyamaha
  • 3,119
  • 2
  • 26
  • 44
-2
votes
1 answer

JSON.stringify doesn't work as expected on changed object. How to handle this?

I have removed my question text, as it didn't address the real error in my code. The two answers fully explain my error, and why I had made it.
John
  • 605
  • 9
  • 28
-2
votes
1 answer

Pull specific data from JSON response

I have a JSON response which I convert to string in javascript by doing var myObject = JSON.stringify(data); This prints out the results fine but I need to be able to pull specific data like myObject.route.locationSequence[1] or…
MahoreLee
  • 143
  • 1
  • 3
  • 12
-3
votes
3 answers

How to JSON.stringify an nested array of objects

This is my data, data = { "SeatingArrangement": [{ "data": [{"id": 1, "rowName": "a", "seatNo": 0},{ "id": 2,"rowName": "a","seatNo": "a1"}], "rowName": "a", }], "TheatreName": "abc natyadalan", …
-3
votes
5 answers

Find a coordinate in a multidimensional array using string search

Try to give an alternative in this question WITHOUT LOOPING! Just using indexOf and some integer math Get coordinates of an element in multidimentional array in Javascript The code below seemed promising but fails. Anyone with better math skills…
mplungjan
  • 169,008
  • 28
  • 173
  • 236
-3
votes
1 answer

remove commas from stringified JSON but not commas separating array

I have stringified JSON data that contains commas in description fields. The AJAX post fails if I have apostrophes OR commas in the data. How can I strip the following from my var test = JSON.stringify(data) test would print out as…
jochanan
  • 15
  • 1
  • 4
-3
votes
1 answer

Angular2 JSON.stringify

Why Angular2 override JSON.stringify !? I have override my own Date.toJSON but it's not called when stringify an object. In the following exemple it's work correctly, but it doesn't work in Angular App ! Custom Date…
usf
  • 1
  • 2
-3
votes
1 answer

How to solve each loop bug within simplified JSON.stringify implementation?

I am using a testing framework to try to return {"foo":true,"bar":false,null} but instead am returning {"foo":true,"bar":false,"baz":null}. After checking the value of result at various points, it appears as though although my each loop is being…
hbrannan
  • 153
  • 1
  • 7
-4
votes
2 answers

Why is JSON.parse(JSON.stringify(json)) != json?

I've searched the internet for an answer and what I found was that JSON.stringify() cannot convert for example functions, only pure data. But this answer couldn't fulfill my need. I need to save the json I requested via fetch in a string because of…
NoahS
  • 21
  • 1
  • 6
-4
votes
1 answer

How to bind json stringify data in golang custom struct type?

How to bind json stringify data in golang custom struct type? js ajax $.ajax({ type: "POST" , url : url , data : JSON.stringify('{"nowBlockPositionX":3,"nowBlockPositionY":0,"nowBlock":{"O":0}}') }) go custom struct type demo struct { …
gdk
  • 89
  • 1
  • 2
  • 11
-4
votes
2 answers

Can't get to work localStorage

I've tried to get a save function getting triggered by a button to work but when I search on every storage possible i don't find anything so I need to know what I'm doing wrong or what lacks the code function savewm(){ var save = { plus1:…
seirei
  • 1
-4
votes
1 answer

Dynamic property Object - JSON

This is my JSON with Javascript: /** * @param {String} value1 * @param {String} value2 * @param {String} value3 * @param {Number} value4 * * @constructor * @properties={typeid:24,uuid:"F146465E-7D8C-4D8B-B37C-954E65AFBEAD"} */ function…
user1911
  • 680
  • 1
  • 14
  • 36
-5
votes
2 answers

I have fetched an API with JS, but the output looks really bad and I don't know how to fix it

I'm trying to fetch an API with Javascript, and it's working, but I can't figure out how to make readable. This is my code: And this is the output: I've done this with ES6 several times, but I don't understand how to do it in vanilla. Newbie…
Cecilia R
  • 3
  • 2
1 2 3
47
48