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
6
votes
4 answers

JSON stringify objects with json strings already as values

Might be a duplicate question, but couldn't find the answer. I want to stringify a javascript object that contains some JSON strings as values. For example: var obj = {id:1, options:"{\"code\":3,\"type\":\"AES\"}"}; As you see, the value for key…
Jeff
  • 524
  • 5
  • 17
6
votes
2 answers

How to split javascript object into smaller parts

I am trying to JSONify a Javascript object only to get "Invalid String Length" error. I decided to break the object up into smaller parts, use JSON.stringify on the smaller parts, and append each segment to the file. I first converted the javascript…
sawa
  • 1,930
  • 3
  • 24
  • 33
6
votes
1 answer

JSON stringify is adding backslashes

When the stringified string is sent to request directly, it is not getting added any slashes. var data = { "A": "Aa", "B": "Bb", "C": "Cc" }; // This is JSON object data = JSON.stringify(data); // Getting stringified var obj =…
Rama Rao M
  • 2,961
  • 11
  • 44
  • 64
6
votes
2 answers

convert invalid JSON string to JSON

I have an invalid json string like following, "{one: 'one', two: 'two'}" I tried to use JSON.parse to convert it to an object. however, this is not valid json string. Is there any functions can convert this invalid format into a valid json string…
eded
  • 3,778
  • 8
  • 28
  • 42
6
votes
2 answers

Stringify JavaScript object

I'm looking to stringify an object. I want in output like this {"1":{"valeur":"dalebrun","usager":"experttasp","date":"2013-08-20 16:41:50"}, "2": {"valeur":"test","usager":"experttasp","date":"2013-08-20 16:41:50"}} But I get…
davidlebr1
  • 423
  • 2
  • 6
  • 16
6
votes
2 answers

Node.js JavaScript-stringify

JSON is not a subset of JavaScript. I need my output to be 100% valid JavaScript; it will be evaluated as such -- i.e., JSON.stringify will not (always) work for my needs. Is there a JavaScript stringifier for Node? As a bonus, it would be nice if…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
6
votes
3 answers

KnockoutJS with IE8, occasional problems with Stringify?

A number of our users are still on IE8. Some of them occasionally are reporting problems when trying to post data to our servers (via a big button labeled "SAVE"). There is a script error that IE8 shows, which is: Unexpected call to method or…
reallyJim
  • 1,336
  • 2
  • 16
  • 32
5
votes
1 answer

How do I pass a dictionary as a parameter when I don't care about a dictionary's types?

Similar to this question: Best way to convert Dictionary into single aggregate String representation? But I want to ignore the types in the Dictionary, since I plan on calling the ToString() method of each key and value. I think it…
Aerik
  • 2,307
  • 1
  • 27
  • 39
5
votes
2 answers

Problem dealing with a space when moving JSON to Python

I am high school math teacher who is teaching myself programming. My apologies in advance if I don't phrase some of this correctly. I am collecting CSV data from the user and trying to move it to a SQLite database via Python. Everything works fine…
MathGuy297
  • 59
  • 5
5
votes
1 answer

Why is JSON.stringify() slow for large objects

I am trying to understand about JSON.stringify() and often times I hear people saying that its very slow for large objects. So I would like to understand what makes JSON.stringify so slow. After researching on the Internet, I found that the…
Sai Raman Kilambi
  • 878
  • 2
  • 12
  • 29
5
votes
0 answers

ArrayBuffer when stringified becomes empty object

In my app, i'm uploading a file using FileReader and parsing it as an ArrayBuffer. The file properties are saved in an object, with structure like this: file: { name: 'fileName', // type string content: ArrayBuffer // read like …
idjuradj
  • 1,355
  • 6
  • 19
  • 31
5
votes
2 answers

How to append JSON data to existing JSON file node.js

How to append an existing JSON file with comma "," as separator anchors = [ { "title":" 2.0 Wireless " } ] fs.appendFileSync('testOutput.json', JSON.stringify(anchors)); This current code's output is like this [ { "title":" 2.0 Wireless…
Tcmxc
  • 481
  • 1
  • 7
  • 23
5
votes
4 answers

JavaScript: Stringify a shallow copy of a circular referenced object?

Is there a way to get just a shallow copy of the below to only get one layer deep? I have a means to fix this using a completely different design but I was wondering if anyone else had ran into what I am trying to convert to a string before. var…
simon
  • 854
  • 1
  • 9
  • 23
5
votes
3 answers

Javascript's JSON.stringify doesn't take key-indexed (associative) arrays?

In JavaScript, you can have objects, like this: var a = { foo: 12, bar: 34 }; Or arrays with key (named) indexes, like this: var b = []; b['foo'] = 56; b['bar'] = 78; They're somewhat similar, but obviously not the same. Now the strange thing is,…
RocketNuts
  • 9,958
  • 11
  • 47
  • 88
5
votes
4 answers

How to convert javascript object into json without using "JSON.stringify" method?

Is there any way to convert javascript object into JSON. I can not use JSON.stringify() Because there is no stringify method in the JSON object in the following link. Link Example: var obj = {'x':1,'y':2} Now if I'll run…
Dixit Singla
  • 2,540
  • 3
  • 24
  • 39