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
4
votes
1 answer

Pass array of objects containing arrays to MVC action via javascript

Say I have a javascript object like: function Parent(n, c) { this.Name = n; this.Children = c; } var p = new Parent("asdf", [1,2,3]); And I want to pass an array of the parent object and its children to an MVC 4 controller via JSON. How…
Hannele
  • 9,301
  • 6
  • 48
  • 68
4
votes
2 answers

Uncaught InvalidStateError in JSON.stringify

I've read this other thread and it was no good: Put data into JSON with Jquery Whenever I try to JSON.stringify an object array I get an error saying: Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer,…
AnimaSola
  • 7,146
  • 14
  • 43
  • 62
4
votes
3 answers

JSON Stringify crashing

I've been testing some code which takes a variable in a json format and should print that, it prints an empty array however. If I'm trying this: console.log(JSON.stringify({first:1,second:2})); Then I'm crashing the page (Chrome: "Aw, Snap!"). I've…
Thomas
  • 649
  • 9
  • 17
4
votes
2 answers

JSON.stringify() alternative and JSON2.js

I am trying to make a WCF call to a function which accepts one String parameter. When I pass parameters from jQuery, I am using JSON.stringify(parameters), where parameters is a name:value collection containing the parameters I want to pass. My…
Harsh Chiki
  • 79
  • 1
  • 10
4
votes
3 answers

Excluding object properties while json-stringifying array object

hey I have a array object something like this [{ public: "public", private: "private", [{ properties: {... }, instance: {..... } }, {... }, {... }] }, {... }, {.... }] Here the outer most…
Ankur
  • 12,676
  • 7
  • 37
  • 67
4
votes
1 answer

json.stringify output is 1023 character...why ?

i have a little big problem, my javascript object is too long, but it is ok. at the moment i use .stringify() function for convert my object in a json string, the string is truncated with "..." and the lenght is 1023. why ? AND how change this…
MrEdodos
  • 71
  • 2
  • 6
3
votes
1 answer

sequential calls of methods asynchronously

I have a list of methods I am calling in a method, as follows: this.doOneThing(); someOtherObject.doASecondThing(); this.doSomethingElse(); When this is synchronous, they are executed one after the other, which is required. But now I have…
Loic Duros
  • 5,472
  • 10
  • 43
  • 56
3
votes
2 answers

JSON to String with inner array convertion

I have a larga data JSON which I want to pass to the backend to be parsed there to become into java objects. To make this I'm using the JSON.stringify function but inside the JSON there is an array attribute that the JSON.stringify is enclosing…
Ronye Vernaes
  • 2,444
  • 1
  • 17
  • 21
3
votes
2 answers

Localstorage: Change value for a specific array using Stringify

I don't know if the question is very accurate but I'm trying to change a value from a localstorage array. This is what my localstorage looks…
jQuerybeast
  • 14,130
  • 38
  • 118
  • 196
3
votes
3 answers

undefined method `stringify_keys' while using Factory Girl

I have the following block of code in my User_spec.rb: @user = { username:'newuser', email:'new@user.com', fname:'new', lname:'user', password:'userpw', password_confirmation:'userpw'} for…
3
votes
1 answer

re-stringify a string in Android

I have a string that i'd like to stringify in Kotlin (Android), but it seems that org.json.* doesn't support taking a string and re-stringifying it, instead it always tries to parse it first. val str = "test=\"123\"" val stringified =…
MrBar
  • 950
  • 6
  • 15
3
votes
3 answers

Detecting parent object when calling JSON.stringify

I have an object, i.e.: { item1: "value1", item2: "value2", item3: { item4: "value4", item5: "value5" } } I want to use JSON.stringify with a replacer function that will act different on items 4 & 5, the inner properties of…
codeKnight
  • 241
  • 2
  • 12
3
votes
0 answers

Redux Persisting a Moment.js Date Object and Stringifying and Parsing Moment.js

I have a moment.js Date object that I work with that I want to persist in redux and redux-persist and then retrieve the Date object from the redux-persist store and work with it again as a moment.js Date object with all of the accompanying functions…
preston
  • 3,721
  • 6
  • 46
  • 78
3
votes
2 answers

How does JSON.stringify automagically convert moment objects to iso strings?

I'm curious how libs like moment, automagically convert from objects to strings when JSON.stringify is called on that object. Example test in moment:…
Catfish
  • 18,876
  • 54
  • 209
  • 353
3
votes
2 answers

Symbol to string with JSON.stringify

I need to convert a Symbol to string in order to create a unique key in Redis, but I can't. I've already tried to use Object.toString(obj) and String(obj) but I get errors or [Object] results¡. This is the controller const name =…
alvarocece
  • 41
  • 4