STRING::UNSTRINGIFY
1g 2023 laplante@plcb.ca GOWEB/STRING — Parse JSON from Stringtitle: “STRING::UNSTRINGIFY” version: “1.0.0” date: 2023 author: “laplante@plcb.ca” section: “1g” category: “GOWEB/STRING”
string::unstringify Parse JSON from String
string::unstringify(expression[, expression, error: variable])
unstringify(expression[, expression, error: variable])
string::unStringify(expression[, expression, error: variable])
unStringify(expression[, expression, error: variable])
The unstringify
function parses a JSON-formatted string and returns the corresponding GoWeb object (array, map, number, boolean, null, etc.).
It is the reverse of stringify
.
res={{
a := [1,2,3];
sa := stringify(a);
unstringify(a); "\n";
a := { "x" : [1,2.2,"3.4", true, false]};
sa := stringify(a);
unstringify(a); "\n";
}}.
Returns:
[1,2,3]
{"x":[1,2.2,"3.4",true,false]}
res={{
x := "[[1,2,3]";
unstringify(error:err,x);
if err != null {
err;
}
}}.
Returns:
string::unstringify : unable to unstringify string: unexpected end of JSON input.
res={{
x := '[1,2.3,"3", true, false, null]';
unstringify(error:err,x);
if err != null {
err;
}
}}.
Returns:
[1,2.3,"3",true,false,null]
res={{
x := '[1,2.3,"3", true, false, null]';
unstringify(error:err,x,x);
if err != null {
err;
}
}}.
Returns:
[[1,2.3,"3",true,false,null],[1,2.3,"3",true,false,null]]
laplante@plcb.ca