Sample code for 30+ languages & platforms
Dart Requires Chilkat v11.4.0+

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final bigCats = '["lion","tiger","leopard","jaguar","cheetah","snow leopard","clouded leopard","cougar","puma","panther"]';

  final json = CkJsonObject();

  json.updateString('test', 'abc');

  try {
    json.newArrayOf('big_cats', bigCats);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  json.emitCompact = false;
  print(json.emit());

  // Result:

  // {
  //   "test": "abc",
  //   "big_cats": [
  //     "lion",
  //     "tiger",
  //     "leopard",
  //     "jaguar",
  //     "cheetah",
  //     "snow leopard",
  //     "clouded leopard",
  //     "cougar",
  //     "puma",
  //     "panther"
  //   ]
  // }
}