Parse and serialize JSON

Verified
Added by iNTERFACEWARE

How to parse and serialize JSON, using json.parse{} and json.serialize{}

Source Code
   -- parse and serialize a JSON string
   
   -- sample JSON string
   local JS = "{'int_test': 1.23, 'string_test':'a', 'boolean_test' : true}"

   -- parse the JSON string into a Lua table
   local JT = json.parse{data=JS}
   
   -- serialize the Lua table into JSON
   local JS = json.serialize{data=JT}
Description
How to parse and serialize JSON, using json.parse{} and json.serialize{}
Usage Details

Demonstrates how to parse and serialize JSON strings, by using json.parse{} and json.serialize{}.

How to use the snippet:

  • Paste the code into your script
  • Inspect the annotations to see how it works