![]() |
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
(Java) 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.
import com.chilkatsoft.*; public class ChilkatExample { static { try { System.loadLibrary("chilkat"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load.\n" + e); System.exit(1); } } public static void main(String argv[]) { // Create JSON with members of different data types. CkJsonObject json = new CkJsonObject(); json.UpdateInt("a",123); json.UpdateBool("b",true); json.UpdateNull("c"); json.put_EmitCompact(false); System.out.println(json.emit()); // Resulting JSON: // { // "a": 123, // "b": true, // "c": null // } String a = json.stringOf("a"); System.out.println(a); String b = json.stringOf("b"); System.out.println(b); String c = json.stringOf("c"); System.out.println(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 int ival = json.IntOf("a"); boolean bval = json.BoolOf("b"); boolean hasNull = json.IsNullOf("c"); } } |
||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.