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

Libraries

json_value