DataFlex
DataFlex
Load JSON Data at Path
See more JSON Examples
Demonstrates how to load JSON data into a path within a JSON database. For example, we begin with this JSON:
{
"a": 1,
"b": 2,
"c": {
"x": 1,
"y": 2
}
}
Then we load {"mm": 11, "nn": 22} to "c", and the result is this JSON:
{
"a": 1,
"b": 2,
"c": {
"mm": 11,
"nn": 22
}
}
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
String p
Handle hoJson
Boolean iSuccess
String q
Variant vC
Handle hoC
String sTemp1
// Demonstrates how to load replace the data at a location within a JSON database.
Move '{"a": 1, "b": 2, "c": { "x": 1, "y": 2 } }' To p
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComLoad Of hoJson p To iSuccess
Set ComEmitCompact Of hoJson To False
Get ComEmit Of hoJson To sTemp1
Showln sTemp1
Move '{"mm": 11, "nn": 22}' To q
Get Create (RefClass(cComChilkatJsonObject)) To hoC
If (Not(IsComObjectCreated(hoC))) Begin
Send CreateComObject of hoC
End
Get pvComObject of c to c
Get ComObjectOf2 Of hoJson "c" c To iSuccess
Get ComLoad Of c q To iSuccess
// See that x and y are replaced with mm and nn.
Get ComEmit Of hoJson To sTemp1
Showln sTemp1
End_Procedure