Sample code for 30+ languages & platforms
React Native

Using JSON StringOf with Non-String Members

See more JSON Examples

If a JSON member is a boolean, integer, or null, using StringOf will return its string representation.

Chilkat React Native Downloads

React Native
import { JsonObject } from '@chilkat/react-native'

function chilkatExample() {
  // Create JSON with members of different data types.
  const json = new JsonObject();

  json.updateInt('a', 123);
  json.updateBool('b', true);
  json.updateNull('c');

  json.emitCompact = false;
  console.log(json.emit());

  // Resulting JSON:
  // {
  //   "a": 123,
  //   "b": true,
  //   "c": null
  // }

  const a = json.stringOf('a');
  console.log(a);

  const b = json.stringOf('b');
  console.log(b);

  const c = json.stringOf('c');
  console.log(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
  const ival = json.intOf('a');
}