wwJsonSerializer::PropertyNameOverrides

Comma delimited list of property names to override on the object to be serialized. Typically used to force property names into proper case rather than the default lower case that is produced by this class by default.

This property only lets you adjust properties for character casing which is a very common use case.

By default the serializer produces all JSON property names as lower case. This option allows you to override this behavior by specifying each property name with formatted casing of your choice.

Applies to objects and cursors. Note that this lookup adds some performance overhead to the parsing so use only if necessary. Specific scenarios include serving data for specific APIs that require a certain format for properties.

If you need more control, you can map an individual property name to a completely new name using MapPropertyName() which can include names that include spaces and special characters.

o.PropertyNameOverrides

Example

do wwJsonSerializer

loObject = CREATEOBJECT("Empty")
ADDPROPERTY(loObject,"Name","Rick")
ADDPROPERTY(loObject,"Company","West Wind")
ADDPROPERTY(loObject,"Entered",DATETIME())

loSer = CREATEOBJECT("wwJsonSerializer")

*** Produces: {"company":"West Wind","entered":"2012-02-27T23:31:49Z","name":"Rick"}
*** Properties are always rendered lower case
? loSer.Serialize(loObject)

*** Make sure these properties render in proper case
loSer.PropertyNameOverrides = "Name,Company,Entered"

*** Produces: {"Company":"West Wind","Entered":"2012-02-27T23:31:49Z","Name":"Rick"}
*** specified properties are overridden
? loSer.Serialize(loObject)

See also:

Class wwJsonSerialize | wwJsonSerializer::MapPropertyName

© West Wind Technologies, 1996-2021 • Updated: 12/20/21
Comment or report problem with topic