Learn JavaScript on the Now Platform: Lesson 30 - JSON Stringify and Parse
ฝัง
- เผยแพร่เมื่อ 17 ม.ค. 2025
- Lesson 30 introduces you to JSON.stringify() and JSON.parse() to translate objects to strings and back again. Watch the video to find out why this is such a powerful JavaScript feature.
GitHub Repo: bit.ly/sn-js
So easy to understand . Thanks chuck for this wonderful tutorials ❤
6:08
Using JSON.stringify - to convert Object to String
Using JSON.parse - to convert String to Object.
Thanks for putting together this video. When it comes to passing JSON data to an API for instance. How do we know whether we need to stringify the JSON object in the post payload. How is that specification usually determined?
Great question. JSON data is always stringified when sent as a payload.
For someone trying to get JSON object from a system property into a script such as a business rule, please note that you do not need to stringify the system property. All you need to do is to parse it to get an object which you can then use in the script.
I have one doubt, in the server side i have create the object then i want to pass that object to client side which is the best way to pass it. please suggest me, Thanks
i could not understand why we are using JSON.stringify(bookList, null, 4) how does that work?
Readability mostly. stringify(obj) outputs in one single line. Using the other two parameters make it easier to read - mainly used in debugging.
@@ChuckTomasi what does (booklist,null,4) null and 4 represent in this
love your bow tie.
Thank you.
Hi, after run script we have a output. That can be downloaded in JSON format
hi, how to get JSON in servicenow from external service, for example openweather?
That could be done with IntegrationHub or using a RESTMessageV2() script API. Check out the free learning plan on Outbound Integrations on our Developer portal. developer.servicenow.com/app.do#!/lp/servicenow_application_developer/app_store_learnv2_rest_madrid_outbound_integrations_in_servicenow_objectives?v=madrid
Can anyone please tell me what 2nd and 3rd values on function call: JSON.stringify(bookList, null, 4) , stands for ?
The second is a 'replacer' function. The third determines the spacing. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
@@ChuckTomasi Thank you so much.