def update_json(self, json_string, expr, value, index=<NUM_LIT:0>):
load_input_json = self.string_to_json(json_string)<EOL>matches = self._json_path_search(load_input_json, expr)<EOL>datum_object = matches[int(index)]<EOL>if not isinstance(datum_object, DatumInContext):<EOL><INDENT>raise JsonValidatorError("<STR_LIT>")<EOL><DEDENT>path = datum_object.path<EOL>if isinstance(path, Index):<EOL><INDENT>datum_object.context.value[datum_object.path.index] = value<EOL><DEDENT>elif isinstance(path, Fields):<EOL><INDENT>datum_object.context.value[datum_object.path.fields[<NUM_LIT:0>]] = value<EOL><DEDENT>return load_input_json<EOL>
Replace the value in the JSON string.

*Args:*\n
_json_string_ - JSON string;\n
_expr_ - JSONPath expression for determining the value to be replaced;\n
_value_ - the value to be replaced with;\n
_index_ - index for selecting item within a match list, default value is 0;\n

*Returns:*\n
Changed JSON in dictionary format.

*Example:*\n
| *Settings* | *Value* |
| Library    | JsonValidator |
| Library    | OperatingSystem |
| *Test Cases* | *Action* | *Argument* | *Argument* |
| Update element | ${json_example}=   | OperatingSystem.Get File |   ${CURDIR}${/}json_example.json |
| | ${json_update}= | Update_json  |  ${json_example}  |  $..color  |  changed |