![]() |
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
(Unicode C) Using JSON StringOf with Non-String MembersSee more JSON ExamplesIf a JSON member is a boolean, integer, or null, usingStringOf will return its string representation.
#include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkJsonObjectW json; const wchar_t *a; const wchar_t *b; const wchar_t *c; int ival; BOOL bval; BOOL hasNull; // Create JSON with members of different data types. json = CkJsonObjectW_Create(); CkJsonObjectW_UpdateInt(json,L"a",123); CkJsonObjectW_UpdateBool(json,L"b",TRUE); CkJsonObjectW_UpdateNull(json,L"c"); CkJsonObjectW_putEmitCompact(json,FALSE); wprintf(L"%s\n",CkJsonObjectW_emit(json)); // Resulting JSON: // { // "a": 123, // "b": true, // "c": null // } a = CkJsonObjectW_stringOf(json,L"a"); wprintf(L"%s\n",a); b = CkJsonObjectW_stringOf(json,L"b"); wprintf(L"%s\n",b); c = CkJsonObjectW_stringOf(json,L"c"); wprintf(L"%s\n",c); // Output // 123 // true // null // If you want to get the integer, boolean, or null value // you need to use the methods matching the data type ival = CkJsonObjectW_IntOf(json,L"a"); bval = CkJsonObjectW_BoolOf(json,L"b"); hasNull = CkJsonObjectW_IsNullOf(json,L"c"); CkJsonObjectW_Dispose(json); } |
||||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.