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
8
votes
3 answers

Using stringify from the v8 shell

I'm creating a v8 shell based console, I took the sample code that cames with v8 and it's working very well, but I'm trying to convert a v8::object to the string version of it (json) but didnt findout a way to do it. Here's my sample code inside the…
Cross
  • 1,436
  • 12
  • 20
8
votes
4 answers

Get JSON stringify value

I have JSON stringify data like this : [{"availability_id":"109465","date":"2017-02-21","price":"430000"},{"availability_id":"109466","date":"2017-02-22","price":"430000"},{"availability_id":"109467","date":"2017-02-23","price":"430000"}] I want to…
Antonio
  • 755
  • 4
  • 14
  • 35
8
votes
2 answers

Convert Object to Array - maintain named keys

I am converting an object into an array. The keys of the object contain names such as "cool", as can be seen below: var obj = { "cool": "Mustang", "family": "Station Wagon", "small": { 0: "small car 1", 1: "small car 2" } }; When…
user3398797
  • 429
  • 1
  • 7
  • 16
8
votes
3 answers

Json Stringify date produces a wrong date compared to javascript date

When i create a javascript date and then stringify it and send it to the server, i get two different dates. The stringified date is always one day behind. So currently i increment my javascript date by 1 day so that i receive the same date on the…
JustLearning
  • 3,164
  • 3
  • 35
  • 52
8
votes
3 answers

Stringify macro with GNU gfortran

How can I stringify a preprocessor macro with GNU gfortran? I would like to pass a macro definition to GNU gfortran which will then be used as a string in the code. Effectively I would like to do this: program test implicit none character (len=:),…
7
votes
2 answers

two ways of creating object in javascript

I'm creating javascript object by doing something like: function field(name,label){ this.name = name this.label= label; } var a = new field("market","Mkt"). Then I assign a to another object. object.newField = a; The second way of…
Progress Programmer
  • 7,076
  • 14
  • 49
  • 54
7
votes
2 answers

Stringify dictionary in Swift

I have an Object of type [Dictionary] [{ "addCity" : "Xyz", "addLandmark" : "Shopper", "addCountry" : "Abc", "addPincode" : "122001", "isPrimary" : "false", "addAddress" : "S44", "addState" : "abc", …
Aditya
  • 783
  • 1
  • 8
  • 25
7
votes
4 answers

Editing JSON search results from within Angular

I am now pulling data from a external JSON URL properly to the master page, but my detail page doesn't seem to pass on the object initallt received from http.get. This master part of the app can be viewed in a Code Pen at CODEPEN
7
votes
1 answer

How to ignore .toJSON function when using JSON.stringify()?

I found out that if you define .toJSON() function for an object, then it's used to stringify an object, rather than default. Is there a way to ignore this overridden function and run the default stringify process?
Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335
7
votes
2 answers

Replacing values in JSON object

I have the following JSON object data returned from my apicontroller : [ {"id":2,"text":"PROGRAMME","parent":null}, {"id":3,"text":"STAGE","parent":2}, {"id":4,"text":"INFRA","parent":2}, {"id":5,"text":"SYSTEM","parent":3}, …
Erwin1
  • 630
  • 2
  • 10
  • 21
7
votes
2 answers

JSON.stringify on nested object ignores nested objects

I'm genereating an object which looks like that when you inspect it with Chrome: When I try to stringify this object with JSON.stringify I get the following result: { "results" : [{ "ID" : 1, "NAME" : "Admin" },…
user2345998
  • 649
  • 13
  • 31
6
votes
2 answers

How do I implement a macro that creates a quoted string for _Pragma?

I want to have a macro that's invoked like this: GCC_WARNING(-Wuninitialized) which expands to code like this: _Pragma("GCC diagnostic ignored \"-Wuninitialized\"") I'm not having luck getting this to work, as the usual tricks of preprocessor…
ThreeBit
  • 608
  • 6
  • 17
6
votes
5 answers

JSON.stringify() and JavaScript Objects

I'm thinking maybe I missed something in JavaScript that I'm just picking up now. I tried this code in Chrome console: a = []; a.name = "test"; JSON.stringify(a); // which returns value [] a = new Object(); a.name = "test"; JSON.stringify(a); //…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
6
votes
1 answer

Why are square brackets needed to stringify all elements of a Map in Javascript?

Problem: I can't seem to find a satisfactory explanation of why javascript Maps need square brackets for the JSON.stringify method to "reach"(?) into the nested elements. I think I'm missing something about ES6, or something inherent to the Map data…
Scott O'Toole
  • 326
  • 3
  • 10
6
votes
2 answers

javaScript: Parsing a stringified object with JSON.parse removes references

I am trying to deep-clone an object, say "a" with k = JSON.parse(JSON.stringify(a)). It is important that I use the stringify way, since I am trying to save the object into a file and then load from it. I stumbled upon a problem with references on…
Martin Antonov
  • 115
  • 1
  • 8