Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Firebase JSON Put and PatchDemonstrates how to apply Firebase put and patch events to a JSON database.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) DECLARE @json1 nvarchar(4000) SELECT @json1 = '{"a": 1, "b": 2}' DECLARE @json int -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Use Firebase delimiters for JSON paths. EXEC sp_OASetProperty @json, 'DelimiterChar', '/' DECLARE @success int EXEC sp_OAMethod @json, 'Load', @success OUT, @json1 EXEC sp_OAMethod @json, 'FirebasePut', @success OUT, '/c', '{"foo": true, "bar": false}' -- Output should be: {"a":1,"b":2,"c":{"foo":true,"bar":false}} EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT '1) ' + @sTmp0 EXEC sp_OAMethod @json, 'FirebasePut', @success OUT, '/c', '"hello world"' -- Output should be: {"a":1,"b":2,"c":"hello world"} EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT '2) ' + @sTmp0 EXEC sp_OAMethod @json, 'FirebasePut', @success OUT, '/c', '{"foo": "abc", "bar": 123}' -- Output should be: {"a":1,"b":2,"c":{"foo":"abc","bar":123}} EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT '3) ' + @sTmp0 -- Back to the original.. EXEC sp_OAMethod @json, 'FirebasePut', @success OUT, '/', '{"a": 1, "b": 2}' EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT '4) ' + @sTmp0 EXEC sp_OAMethod @json, 'FirebasePut', @success OUT, '/c', '{"foo": true, "bar": false}' EXEC sp_OAMethod @json, 'FirebasePatch', @success OUT, '/c', '{"foo": 3, "baz": 4}' -- Output should be: {"a":1,"b":2,"c":{"foo":3,"bar":false,"baz":4}} EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT '5) ' + @sTmp0 EXEC sp_OAMethod @json, 'FirebasePatch', @success OUT, '/c', '{"foo": "abc123", "baz": {"foo": true, "bar": false}, "bax": {"foo": 200, "bar": 400} }' -- Output should be: {"a":1,"b":2,"c":{"foo":"abc123","bar":false,"baz":{"foo":true,"bar":false},"bax":{"foo":200,"bar":400}}} EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT PRINT '6) ' + @sTmp0 EXEC @hr = sp_OADestroy @json END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.