The JSON module, which is available in all script without dedicated import,
parses a JSON string into a data structure of Maps, Lists and primitive types like Integer,
Double, Boolean and String. Serializing is done via the stringify() method.
Note: In order to read structured JSON data from a QF-Test variable use the rc.getJson() call.
| |
|
| |
Object parse(Object text, Object reviver=None) |
| Parameters |
text |
The String or InputStream to parse as JSON.
|
reviver |
(Optional) If a function or Groovy Closure, this prescribes how each value originally produced by parsing is
transformed before being returned. Non-callable values are ignored.
|
| Returns | The Map, List, String, Number, Boolean, or null value corresponding to the given JSON text. |
| |
Object stringify(Object value, Object replacer=None, Object space=None) |
| Parameters |
value |
The value to convert into a JSON string.
|
replacer |
(Optional) A function that alters the behavior of the stringification process, or an array of strings and numbers
that specifies properties of value to be included in the output.
If replacer is anything other than a function or an array, all string-keyed
properties of the object are included in the resulting JSON string.
|
space |
(Optional) A string or number that's used to insert white space (including indentation, line break characters, etc.)
into the output JSON string for readability purposes.
-
If this is a number, it indicates the number of space characters to be used as indentation,
clamped to 10 (that is, any number greater than 10 is treated as if it were 10).
Values less than 1 indicate that no space should be used.
-
If this is a string, the string (or the first 10 characters of the string, if it's longer than that)
is inserted before every nested object or array.
-
If space is anything other than a string or number - for example, is null or not provided - no white space is used.
|
| Returns | A JSON string representing the given value, or null. |
| |
|
| |