Dart
Dart
Load a JSON Array
See more JSON Examples
The Chilkat JSON API requires the top-level JSON to be an object. Therefore, to load an array requires that it first be wrapped as an object.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// Imagine we want to load this JSON array for parsing:
final jsonArrayStr = '[{"id":200},{"id":196}]';
// First wrap it in a JSON object by prepending "{ "array":" and appending "}"
final sbJson = CkStringBuilder();
sbJson.append('{"array":');
sbJson.append(jsonArrayStr);
sbJson.append('}');
final json = CkJsonObject();
json.load(sbJson.getAsString());
// Now we can get the JSON array
final jArray = json.arrayAt(0);
// Do what you want with the JSON array...
// For example:
final jObjId = jArray.objectAt(0);
print(jObjId.intOf('id'));
}