setValueInJson function

dynamic setValueInJson(
  1. Json json,
  2. SimpleJsonPath path,
  3. dynamic value
)

will set a value at specific position in a json

@hint if path points to an existing element, it will be overwritten! @hint this is an inplace operation!

Implementation

setValueInJson(Json json, SimpleJsonPath path, dynamic value) {
  var parent = getByPath(json, path.sublist(0, path.length - 1));
  var key = path.last;

  parent[key] = value;
}