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

A Flutter plugin which support read, write and delete on json string using json Path.

example/example.dart

import 'package:dart_json_path/dart_json_path.dart';

main() {
  writeInJson();
  writeJsonInArray();
  readJson();
}

void writeJsonInArray() {
  var jsonPath = JsonPath.getInsatnce();
  var myJSON = '{ "name" : "vinay", "age":31, "city":"New York"}';
  var path = "\$.address[0].city";
  var nodeValue = "Agra";
  var outPut = jsonPath.write(myJSON, path, nodeValue);
  print(outPut);

  /// Output will be like this.
  ///{"name":"vinay","age":31,"city":"New York","address":[{"city":"Agra"}]}
}

void writeInJson() {
  var jsonPath = JsonPath.getInsatnce();
  var myJSON = '{ "age":31, "city":"New York"}';
  var path = "\$.name.firstName";
  var nodeValue = "Vinay";
  var outPut = jsonPath.write(myJSON, path, nodeValue);
  print(outPut);

  /// Output will be like this.
  /// {"age":31,"city":"New York","name":{"firstName":"Vinay"}}
}

void readJson() {
  var jsonPath = JsonPath.getInsatnce();
  var myJSON =
      '{"name":"vinay","age":31,"city":"New York","address":[{"city":"Agra"}]}';
  var path = "\$.address[0].city";
  var outPut = jsonPath.read(myJSON, path);
  print(outPut);

  ///output will be like this
  ///Agra
}
1
likes
40
pub points
10%
popularity

Publisher

unverified uploader

A Flutter plugin which support read, write and delete on json string using json Path.

Repository (GitHub)
View/report issues

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on dart_json_path