Not the most optimized, but easy to code: use JSONObject .
Iterate over your records and put them into a JSONObject (converting each value to a JSONValue appropriate type), then call toString to get a JSON view.
For parsing, return JSONObject back using JSONParser , then go through the keySet , get values ββand put them on your map (after JSONValue s)
But be careful with the keys you use! You cannot use any key as a property name in JS; and JSON processing in the browser always involves going through a JS object (or the JSON parser itself, which will not do the same)
source share