Comma delimited list of property names to override in the result JSON document.
This property allows you to easily transform one or more JSON properties by overriding their character character casing. JavaScript and JSON are case-sensitive, but FoxPro cannot easily determine case from a property/value/field, and wwJsonSerializer by default only generates lower case property names. This properties let you specify properly cased property names and apply them to the JSON document.
To use, you specify a comma delimited list of properly cased names that need to be not-only-lowercase by specifying the properly cased name. The original lower case names are are then replaced with the properly cased names in the entire result JSON document.
This operation works on the result JSON string, by looking up each property in an case-insensitive manner, and replacing each property with the case-sensitive value you provided.
Works on the Entire JSON Document
The property overrides are applied through the entire JSON document and JSON object hierarchy, so it updates JSON properties in top level objects, child objects and child arrays recursively.
Completely re-map a Property Name with MapPropertyName()
If you need more naming control, or need to map a property to a new name that changes more than just case, you can map an individual property using MapPropertyName(). This method also allows mapping to names that are not valid FoxPro property names including those that include spaces and special characters.
o.PropertyNameOverrides
Example
do wwJsonSerializer
loObject = CREATEOBJECT("Empty")
ADDPROPERTY(loObject,"FirstName","Rick")
ADDPROPERTY(loObject,"Company","West Wind")
ADDPROPERTY(loObject,"DateEntered",DATETIME())
loSer = CREATEOBJECT("wwJsonSerializer")
*** Produces: {"company":"West Wind","dateentered":"2012-02-27T23:31:49Z","firstname":"Rick"}
*** Properties are always rendered lower case
? loSer.Serialize(loObject)
*** Override the two properties that need to be case sensitive
loSer.PropertyNameOverrides = "firstName,dateEntered"
*** Produces: {"company":"West Wind","dateEntered":"2012-02-27T23:31:49Z","firstName":"Rick"}
*** specified properties are overridden
? loSer.Serialize(loObject)
See also:
Class wwJsonSerialize | wwJsonSerializer::MapPropertyName© West Wind Technologies, 1996-2024 • Updated: 01/31/23
Comment or report problem with topic