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

Copy JSON Object from one JSON Array to Another

See more JSON Examples

Demonstrates how to copy an object in a JSON array to another JSON array.

Chilkat Dart Downloads

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

void main() {
  final arr1 = CkJsonArray();
  final arr2 = CkJsonArray();

  final s = '[{"a":1}, {"b":2}, {"c":3}]';
  final sEmpty = '[]';

  arr1.load(s);
  arr2.load(sEmpty);

  final jObj = CkJsonObject();
  arr1.objectAt2(1, jObj);

  arr2.addObjectCopyAt(-1, jObj);

  print(arr2.emit());

  // output is:   [{"b":2}]
}