json_value 1.1.1 copy "json_value: ^1.1.1" to clipboard
json_value: ^1.1.1 copied to clipboard

using json_value,we can get the value from Json data more easily.

JsonValue #

It's easier to get the values from Jaon data

Getting Started #

Add this to your package's pubspec.yaml file:

dependencies:
  json_value: "^1.0.0"

Why is it not good to get value from json #

if response like this

{
    "user":{
        "name":"Jack",
        "age":20
    },
    "fruits":[
        {
            "name":"apple",
            "detail":"apple is sweet"
        },{
            "name":"watermelon",
            "detail":"watermelon is full of water",
        }
    ]
}

if you want to get user->name ,on the safe side ,you will code like this:

if(response is Map<String,dynamic>){
  var user = response['user'];
  if (user is Map<String,dynamic>){
      var name = user['name'];
  }

}

With JsonValue all you have to do is:

JsonValue json = JsonValue(response);
var name = json['user']['name'].stringValue;
var fruits = json['fruits'].listValue;
var appleName = json['fruits'][0]['name'].stringValue;

You don't worry about array overstepping . It`s safe

5
likes
130
pub points
0%
popularity

Publisher

unverified uploader

using json_value,we can get the value from Json data more easily.

Homepage

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on json_value