jsonx 1.0.0 copy "jsonx: ^1.0.0" to clipboard
jsonx: ^1.0.0 copied to clipboard

discontinued
outdatedDart 1 only

An extended JSON library that supports the encoding and decoding of arbitrary objects.

Beyond primitives, lists, and maps #

jsonx is an extended JSON library that supports the encoding and decoding of arbitrary objects. The best thing of jsonx is it allows code completion.

Example #

import 'jsonx.dart';

class Person {
  String name;
  int age;
  List<Person> children;
}

main() {
  var c1 = new Person()
      ..name = 'child 1'
      ..age = 10;

  var c2 = new Person()
      ..name = 'child 2'
      ..age = 8;

  var p1 = new Person()
      ..name = 'parent'
      ..age = 40
      ..children = [c1, c2];

  var s1 = encode(p1);
  print(s1); // {"name":"parent","age":40,"children":[{"name":"child 1","age":10,"children":null},{"name":"child 2","age":8,"children":null}]}

  Person p2 = decode(s1, type: Person);
  print(p2.name); // parent

  var s2 = encode(p2);
  print(s2); // {"name":"parent","age":40,"children":[{"name":"child 1","age":10,"children":null},{"name":"child 2","age":8,"children":null}]}

  List<String> list = decode('["green", "yellow", "orange"]',
      type: <String>[].runtimeType);
  print(list[1]); // yellow
}
0
likes
0
pub points
23%
popularity

Publisher

unverified uploader

An extended JSON library that supports the encoding and decoding of arbitrary objects.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on jsonx