Sample code for 30+ languages & platforms
React Native Requires Chilkat v11.0.0+

JSON AppendObject2 Example

Demonstrates the AppendObject2 function.

Chilkat React Native Downloads

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

function chilkatExample() {
  const json = new JsonObject();
  json.load('{ "name": "John", "marbles": 100 }');

  // Append an empty object named "addr"
  const jObj = new JsonObject();
  json.appendObject2('addr', jObj);

  console.log(json.emit());
  // Expected output is:   {"name":"John","marbles":100,"addr":{}}

  // Add members to the object.
  jObj.appendString('street', '1200 Elm St.');
  jObj.appendString('city', 'Springfield');
  jObj.appendInt('zip', 60606);

  console.log(json.emit());
  // Expected output is:  {"name":"John","marbles":100,"addr":{"street":"1200 Elm St.","city":"Springfield","zip":60606}}
}