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

Stringify a multi-dimension array with javascript

Im creating an invoice for books, and aim to submit it via ajax. Im trying to json encode the array of books in the invoice, however I keep getting a blank value //create item list var order_items = []; $('#mi_books tbody…
pinkpixycoder
  • 91
  • 2
  • 6
4
votes
1 answer

Passing variable name as string to function with default parameters

Let’s say there is a debugging function, simplified here as: void DumpString(char* var, char* varname) { printf("%s : '%s'\n", varname, var); } char str[10]="foobar"; DumpString(str, "str"); > str : foobar Let’s make it easier by removing the…
Synetech
  • 9,643
  • 9
  • 64
  • 96
4
votes
2 answers

boost::lexical_cast and stringification of non-builtin types

I have a (maybe) simple problem about boost::lexical_cast with composite types (in my case std::vector. My first version of a templatized stringification function was the following template std::string stringiy(const T…
linello
  • 8,451
  • 18
  • 63
  • 109
4
votes
3 answers

Print JSON to screen for use with cut and paste

This is going to sound really ghetto, but I need to print some Javascript to the browser screen so that it can be cut and pasted into another program. I'm using JSON.stringify() from json2.js, however, its not escaping characters such as quotes and…
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
4
votes
1 answer

How to prettify JSON.stringify() partially?

Users can download JSON files from our application, which I want to prettify for easier debugging than if all is in one line. However this increases the file size by nearly 40% even if the indentation is just a single tab or space. As a compromise,…
Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
4
votes
5 answers

How to import qs in react

I searched about [How to use qs in react] but can't find the answer. Qs's official site https://www.npmjs.com/package/qs Usage qs = require('qs'); var assert = require('assert'); var obj = qs.parse('a=c'); assert.deepEqual(obj, { a: 'c' }); var…
trinitrotoluene
  • 307
  • 2
  • 5
  • 14
4
votes
2 answers

How to verify stringified json in pact

I am trying to build a pact between two services using asynchronous communication. This is the code I used for generate the pact: @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "provider", providerType =…
4
votes
4 answers

How can I convert a Request object into a stringifiable object in JavaScript?

Using Object methods like entries and keys produce empty arrays. JSON.stringify yields an empty object in the browser and a circular reference error in Node.js. const request = new Request( 'https://example.com/send', { method:…
jsejcksn
  • 27,667
  • 4
  • 38
  • 62
4
votes
0 answers

Error message: Unresolved variable or type JSON (stringify)?

I got this really unexpected error message when trying to do: localStorage.setItem('user', JSON.stringify(user)); Unresolved variable or type JSON Im working in an Angular Typescript file. I have looked on the internet for a solution but nothing…
Y_Lakdime
  • 825
  • 2
  • 15
  • 33
4
votes
1 answer

JavaScript JSON stringify: make it output a one-line compact string

I'm trying to create a custom function for converting a JSON object to a one-line string. For example: var obj = { "name": "John Doe", "age": 29, "location": "Denver Colorado", }; I would like to make it output: "{ \"name\": \"John Doe\",…
TonyW
  • 18,375
  • 42
  • 110
  • 183
4
votes
2 answers

Parse a Bundle which is a JSONString in Remotemessage to JSON object

I am trying to parse the notification data in FCM. I will try to explain my problem as detailed as i can. I have to two apps one is android and the other is javascript webapp. so when sending pushnotification from webapp to androd app I am sending…
Stackover67
  • 347
  • 2
  • 4
  • 18
4
votes
0 answers

stringify/casting jsonb to string w/reliable whitespacing for hash in postgresql similar to JSON.stringify

I'm looking to create a hashing function for jsonb fields, but need to control the casting to string to allow for client and server integrity. In other words, I'd like to stringify JSON on both client and server with the same spacing and…
pyramation
  • 1,631
  • 4
  • 22
  • 35
4
votes
2 answers

Javascript stringify '%%' loses a percent sign

Why is the output of stringify missing a percent sign? var a = ["dp",'%%']; var t = JSON.stringify (a); console.log ('t: ' + t); Result is: t: ["dp","%"] Why isn't the result: t: ["dp","%%"] Thanks!
tgoneil
  • 1,522
  • 3
  • 19
  • 30
4
votes
2 answers

Convert string to a name identifer

Is the "destringification" possible in C89 just like stringification is possible?
Alan Salios
  • 241
  • 2
  • 9
4
votes
0 answers

Stringify single and double quotes

With the following code I am creating an object to pass to a webservice. The single quote seems to be handled with a replace in the stringify before the object is passed to the service, but I don't know how to modify the double quote. If I inspect…
Tom S
  • 227
  • 1
  • 6
  • 19