(PureBasic) JSON PathPrefix Example
Demonstrates the JSON object's PathPrefix property.
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
success.i = 0
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::setCkPathPrefix(json, "company.billing.")
CkJsonObject::ckUpdateString(json,"company_name","TechNova Solutions Inc.")
CkJsonObject::ckUpdateString(json,"address_line_1","123 Innovation Drive")
CkJsonObject::ckUpdateString(json,"address_line_2","Suite 450")
CkJsonObject::ckUpdateString(json,"city","Seattle")
CkJsonObject::ckUpdateString(json,"state_province","WA")
CkJsonObject::ckUpdateString(json,"postal_code","98101")
CkJsonObject::ckUpdateString(json,"country","USA")
CkJsonObject::setCkEmitCompact(json, 0)
Debug CkJsonObject::ckEmit(json)
; Result:
; {
; "company": {
; "billing": {
; "company_name": "TechNova Solutions Inc.",
; "address_line_1": "123 Innovation Drive",
; "address_line_2": "Suite 450",
; "city": "Seattle",
; "state_province": "WA",
; "postal_code": "98101",
; "country": "USA"
; }
; }
; }
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure
|