Javascript JSON to string
Into this post we are going to discuss how to convert Javascript JSON ( Javascript Object Notation ) to string or javascript json to string.
Into this kind real IT world we can say Javascript is everywhere like front end and BackEnd both so we can say Javascript is going to rule everywhere.
So in today's article we are going to discuss JSON which generally uses to pass data from one end to another end.
Let start understanding of that using below simple examples.
So into Javascript we can do that easily using JSON.stringify().
First let's take and example of Object let json_to_string = JSON.stringify({ javascript_json: 5, json_to_string: 6 }) console.log(json_to_string); //output: "{"javascript_json":5,"json_to_string":6}"
Now let's take an example of run time creation of Array of Object let json_to_string = JSON.stringify([new String('visiofortech'),new Boolean(false),new Number(7)]) console.log(json_to_string); //output: "["visiofortech",false,7}"
Now let's take an example of Date object let json_to_string = JSON.stringify(new Date(2018, 10, 16, 15, 4, 5)) console.log(json_to_string); //output: ""2018-11-16T09:34:05.000Z""
Hope you enjoyed the article and it got added something new to your knowledge.
To add something new every-time into your mind stay tuned to visionfortech.
To Learn more about Javascript Javascript Treasure.
Please comment below if you have something doubts or some questions.
Enjoy...!!!
Happy Learning....!!!
Comments
Post a Comment