|  | 
Chilkat  HOME  Android™  AutoIt  C  C#  C++  Chilkat2-Python  CkPython  Classic ASP  DataFlex  Delphi DLL  Go  Java  Node.js  Objective-C  PHP Extension  Perl  PowerBuilder  PowerShell  PureBasic  Ruby  SQL Server  Swift  Tcl  Unicode C  Unicode C++  VB.NET  VBScript  Visual Basic 6.0  Visual FoxPro  Xojo Plugin
| (PureBasic) Firebase JSON Put and PatchDemonstrates how to apply Firebase put and patch events to a JSON database. 
 IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() json1.s = "{" + Chr(34) + "a" + Chr(34) + ": 1, " + Chr(34) + "b" + Chr(34) + ": 2}" json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Use Firebase delimiters for JSON paths. CkJsonObject::setCkDelimiterChar(json, "/") CkJsonObject::ckLoad(json,json1) CkJsonObject::ckFirebasePut(json,"/c","{" + Chr(34) + "foo" + Chr(34) + ": true, " + Chr(34) + "bar" + Chr(34) + ": false}") ; Output should be: {"a":1,"b":2,"c":{"foo":true,"bar":false}} Debug "1) " + CkJsonObject::ckEmit(json) CkJsonObject::ckFirebasePut(json,"/c",Chr(34) + "hello world" + Chr(34)) ; Output should be: {"a":1,"b":2,"c":"hello world"} Debug "2) " + CkJsonObject::ckEmit(json) CkJsonObject::ckFirebasePut(json,"/c","{" + Chr(34) + "foo" + Chr(34) + ": " + Chr(34) + "abc" + Chr(34) + ", " + Chr(34) + "bar" + Chr(34) + ": 123}") ; Output should be: {"a":1,"b":2,"c":{"foo":"abc","bar":123}} Debug "3) " + CkJsonObject::ckEmit(json) ; Back to the original.. CkJsonObject::ckFirebasePut(json,"/","{" + Chr(34) + "a" + Chr(34) + ": 1, " + Chr(34) + "b" + Chr(34) + ": 2}") Debug "4) " + CkJsonObject::ckEmit(json) CkJsonObject::ckFirebasePut(json,"/c","{" + Chr(34) + "foo" + Chr(34) + ": true, " + Chr(34) + "bar" + Chr(34) + ": false}") CkJsonObject::ckFirebasePatch(json,"/c","{" + Chr(34) + "foo" + Chr(34) + ": 3, " + Chr(34) + "baz" + Chr(34) + ": 4}") ; Output should be: {"a":1,"b":2,"c":{"foo":3,"bar":false,"baz":4}} Debug "5) " + CkJsonObject::ckEmit(json) CkJsonObject::ckFirebasePatch(json,"/c","{" + Chr(34) + "foo" + Chr(34) + ": " + Chr(34) + "abc123" + Chr(34) + ", " + Chr(34) + "baz" + Chr(34) + ": {" + Chr(34) + "foo" + Chr(34) + ": true, " + Chr(34) + "bar" + Chr(34) + ": false}, " + Chr(34) + "bax" + Chr(34) + ": {" + Chr(34) + "foo" + Chr(34) + ": 200, " + Chr(34) + "bar" + Chr(34) + ": 400} }") ; Output should be: {"a":1,"b":2,"c":{"foo":"abc123","bar":false,"baz":{"foo":true,"bar":false},"bax":{"foo":200,"bar":400}}} Debug "6) " + CkJsonObject::ckEmit(json) CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure | ||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.