STRING::STRINGIFY 1g 2024-09-01 laplante@plcb.ca GOWEB/STRING — Convert Expression to String


title: “STRING::STRINGIFY” version: “1.0.0” date: 2024-09-01 author: “laplante@plcb.ca” section: “1g”

category: “GOWEB/STRING”

Name

string::stringify Convert Expression to String

Synopsis

string::stringify(expression[, expression, html: bool, error: variable, space: bool, newline: bool, indent: bool])
stringify(expression[, expression, html: bool, error: variable, space: bool, newline: bool, indent: bool])

Description

The stringify function takes an expression (commonly JSON) and converts it into a string representation.

Parameters


Examples

res={{
    a := null;
    m := { "x" : [1,"2.", 3.4]};
    stringify([m, a, "x","ééé世界\t", 4, 6, 7, 3.1415926535, false, true, a, { "9" : 9, "1" : [1,"2.", 3.4], "8": 8}]);
}}.

Returns:

[{"x": [1, "2.", 3.4]}, null, "x", "ééé世界\t", 4, 6, 7, 3.1415926535, false, true, null, {"1": [1, "2.", 3.4], "8": 8, "9": 9}]

res={{
    a := null;
    m := { "x" : [1,"2.", 3.4]};
    stringify(space:false, [m, a, "x","ééé世界\t", 4, 6, 7, 3.1415926535, false, true, a, { "9" : 9, "1" : [1,"2.", 3.4], "8": 8}]);
}}.

Returns:

[{"x":[1,"2.",3.4]},null,"x","ééé世界\t",4,6,7,3.1415926535,false,true,null,{"1":[1,"2.",3.4],"8":8,"9":9}]

res={{
    a := null;
    m := { "x" : [1,"2.", 3.4]};
    stringify(newline:true, [m, a, "x","ééé世界\t", 4, 6, 7, 3.1415926535, false, true, a, { "9" : 9, "1" : [1,"2.", 3.4], "8": 8}]);
}}.

Returns (multi-line):

[
{
"x": [
1,
"2.",
3.4
]
},
null,
"x",
"ééé世界\t",
4,
6,
7,
3.1415926535,
false,
true,
null,
{
"1": [
1,
"2.",
3.4
],
"8": 8,
"9": 9
}
]

res={{
    a := null;
    m := { "x" : [1,"2.", 3.4]};
    stringify(indent:true, [m, a, "x",[9,8,7,6.2], "ééé世界\t", 3, 6, 7, 3.1415926535, false, true, a, { "9" : 9, "1" : [1,"2.", 3.4], "8": 8}]);
}}.

Returns (indented):

[
   {
    "x": [
         1,
         "2.",
         3.4
      ]
   },
   null,
   "x",
   [
      9,
      8,
      7,
      6.2
   ],
   "ééé世界\t",
   3,
   6,
   7,
   3.1415926535,
   false,
   true,
   null,
   {
    "1": [
         1,
         "2.",
         3.4
      ],
    "8": 8,
    "9": 9
   }
]

res={{
    a := null;
    m := { "x" : [1,"2.", 3.4]};
    stringify(error:err,xindent:true, [m, a, "x",[9,8,7,6.2], "ééé世界\t", 3, 6, 7, 3.1415926535, false, true, a, { "9" : 9, "1" : [1,"2.", 3.4], "8": 8}]);
    "error="; err;
}}.

Returns:

error=string::stringify : this parameter 'xindent' is not supported.

Author

laplante@plcb.ca

See Also


Version