decode method Null safety

dynamic decode (
  1. String gson,
  2. {dynamic simplify = false}
)

Decode gson

gson.decode("{hello: "world"}") // >> {"hello": "world"}

if you want to have easy-usable contents set simplify to true, the simplify method will be automatically ran over your results. Simplify converts gson results to something you can easily deal with. some of these changes can't be recreated from the results. Also in gson booleans are encoded as bytes and bytes are converted to integers in here, so instead of a true you will probably get 1 and instead of false 0. The results are just compatible with the json library of dart if you use simplify

json.encode( gson.decode("{hello: "world"}", simplify: true) );  // >> {"hello": "world"}

Implementation

dynamic decode(String gson, {simplify = false}) {
  return simplify
      ? this.simplify(decoder.decode(gson))
      : decoder.decode(gson);
}