wwJsonSerializer::Serialize

Serializes a FoxPro value to a JSON string. Supports all VFP basic types, most complex objects (as long as there are no circular references), simple arrays and collections and cursors.

To serialize simple values:

ltToday = DateTime() loSerializer = CREATEOBJECT("wwJsonSerializer") lcJSON = loSerializer.Serialize(ltToday)

To serialize an object:

*** Serialize an object (single or nested hierarchy) SELECT Customer SCATTER NAME loCustomer lcJSON=loSerializer.Serialize(loCustomer)

Cursors serialize like an array of object with a root node call Rows and an array of each row as an object.

Since cursors cannot be passed as a value to the Serialize() function special syntax is used:

cursor:<AliasName>

To serialize a FoxPro cursor or table:

select * from tt_cust into TCustomers loSerializer = CREATEOBJECT("wwJsonSerializer") lcJSON = loSerializer.Serialize("cursor:TCustomers")

Property and Fieldnames are always Lower Case
Please note that all object and cursor property/field names are serialized in lower case due to Visual FoxPro's inability to reliably provide case sensitive type information.


o.Serialize(lvValue)

Return Value

Serialized JSON string

Parameters

lvValue

See also:

Class wwJsonSerializer


  Last Updated: 12/16/2008 | © West Wind Technologies, 2008