I'm using Delphi 2010 and superobject library.
I have understand how to parse json-file, but I have no ideas how to create json?
The algorithm is:
- Parsing JSON and load in TStringGrid
- Adding data
- Save all TStringGrid data to json.
Need some example.
Thanks.
Code sample to feed following structure to JSON object, then save to file:
Reading help file: https://github.com/hgourvest/superobject/blob/master/README.md
And then reading sources for TSuperArray ('Use the source, Luke')
Results in the following snippet:
There is also the quote from help file: obj['foo[]'] := value; // add an item array
This suggests another way to populate an array (if the root object itself is not an array). Quoting http://code.google.com/p/superobject/source/browse/tests/test_usage.dpr
And later this object-array is inserted as property into yet another object
A very good library for that is the LkJson: http://sourceforge.net/projects/lkjson/
To parse:
var jsText : String; jsObj : TlkJSONobject; begin
To convert it back into text: