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

outdated

It's easier to get the value from Json data

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: "^0.0.4"

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
0
pub points
0%
popularity

Publisher

unverified uploader

It's easier to get the value from Json data

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on json_value