Load a JSON string into a data structure.
Also, create a new data structure and serialize it into JSON.

Use objects and arrays (as appropriate for your language)
and make sure your JSON is valid (https://jsonformatter.org).

//--------------------------------------
// Simple (unsafe) JSON decoder based on eval()
// @param {string} json
// @return {any}
//--------------------------------------
function json_decode (json){
  var o;
  eval('o='+json);
  return _json_decode_val(o);
}
 
function _json_decode_val (o){
  if (o==null) return undefined;
  switch(typeof(o)){
    case "object":
      if (o instanceof Array){
        var v = list();
        var cnt = o.length;
        for (i=0;i<cnt;i++){
          v.add(_json_decode_val(o[i]));
        }
      }else{
        var v = propList();
        for (var i in o){
          var p = i;
          v.setAProp(_json_decode_val(p), _json_decode_val(o[i]));
        }
      }
      return v;
    case "string":
      // optional support of special Lingo data type 'symbol' unknown to JavaScript
      if (o.substr(0,7)=='__sym__') return symbol(o.substr(7));
      return o;
    default:
      return o;
  }
}
 
function _json_escape_string (str){
  var hash={"\\":"\\\\", "/":"\\/", "\n":"\\n", "\t":"\\t", "\r":"\\r", "\b":"\\b", "\f":"\\f", "\"":"\\\""};
  var patt = "["; for (i in hash) patt+=i;patt+="]";
  return str.replace(RegExp(patt, "g"), function(c){
    return hash[c]
  });
}