You are currently looking at the v11.0 docs, which are still a work in progress. If you miss anything, you may find it in the older v10.0 docs here.
JSON
Parse
Bind to JavaScript's JSON.parse
and type the return value as the type you're expecting:
Where data
can be any type you assume the JSON is. As you can see, this compiles to a straightforward JSON.parse
call. As with regular JS, this is convenient, but has no guarantee that e.g. the data is correctly shaped, or even syntactically valid. Slightly dangerous.
Stringify
Use Js.Json.stringify
:
Advanced
The Js.Json module provides slightly safer, low-level building blocks for power users who want to parse JSON on a per-field basis. See the examples in the API docs.