Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JSON to string

var sample  = {
	name: "Himansu Jangid",
  	github: "https://github.com/himanshurajora",
  	age: 19
}
var converted = JSON.stringify(sample);
// now the converted variable contains stringified json object in the single line
// ------------
// to keep the json structure 
converted = JSON.stringify(sample, null, '	');
// now the object will be stringified but the structure will remain same
// output - '{
	"name": "Himansu Jangid",
	"github": "https://github.com/himanshurajora",
	"age": 19
}'
 
PREVIOUS NEXT
Tagged: #JSON #string
ADD COMMENT
Topic
Name
3+4 =