Allows you to map a property name in a JSON string to a new name. This can be useful if you created JSON from a FoxPro objects, but need to create a property name that FoxPro's property limitations don't allow for, such as property names with spaces or special characters.

Unlike PropertyNameOverrides which can only transform case on properties, the MapPropertyName() method allows you to map property names to any value including those that FoxPro properties would not otherwise support, such as names with spaces or special characters.

o.MapPropertyName(@lcJson, lcOriginal,lcNewName)

Return Value

(preferrably pass by reference and ignore) - otherwise returns updated JSON string


The JSON document as a string. Preferrably pass by reference so the value is updated in place. Otherwise the method can return the new JSON string.

The original name to replace in the JSON string

The name to change it to.


The following example creates JSON properties with spaces:

loSer = CREATEOBJECT("wwJsonSerializer")

*** Create initial JSON
*** { "lastname": "Strahl", "firstname": "Rick" }
lcJson = loSer.Serialize(loObj)

*** Now update the property names
loSer.MapPropertyName(@lcJson, "lastName","Last Name")
loSer.MapPropertyName(@lcJson, "firstName","First Name")

*** { "Last Name": "Strahl", "First Name": "Rick" }
? lcJson

See also:

Class wwJsonSerializer | wwJsonSerializer::PropertyNameOverrides

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