wwJsonSerializer currently doesn't support two-way serialization of cursors. Cursors are supported only one way - outbound.
There are a number of issues in de-serializing JSON data, from data type concerns (there's no schema) and some internal concerns since this is a one pass parser. The parser also doesn't support de-serialization of arrays and collections.
However - I spent some time today adding array support to wwJsonSerializer, so arrays should now work. THis also means you can serialize a cursor and then deserialize and get an object back.
I've attached the updated version here (note there's an extra depndency on the wwCollection class.
Do wwJsonSerializer loJson = CREATEOBJECT("wwJsonSerializer") ? "*** Cursor Serialization" USE wwdemo\TT_CUST SELECT TOP 3 company,Careof as name, entered ; FROM tt_cust ; ORDER BY company ; INTO CURSOR TQuery lcJson = loJson.Serialize("cursor:TQuery") ? lcJson ? "*** De-serialize cursor JSON to object - Note not a cursor!" loResult =loJson.Deserialize(lcJson) ? loResult ? loResult.Rows.Count FOR lnX = 1 TO loResult.Rows.Count loCust = loResult.Rows.Item(lnX) ? loCust.Company,loCust.Name,loCust.Entered ENDFOR ? "*** Reserialize result object - outputs as an object" lcJson = loJson.Serialize(loResult) ? lcJson ?
The result is an object with a Rows property and a wwCollection object. You can access the object with the wwCollection methods/properties or directly access the wwCollection::aItems array which you can iterate through to re-populate DBF data if necessary.
Hope this helps,
+++ Rick ---
A few more details
The line that errors is:
ADDPROPERTY(loObject,lcProperty, this.Deserialize(lcValue) )
The values of the memory variables on the above line at time of error:
lcProperty= [{"Campaign
lcValue = "Red"