Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning

Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8 for Server/Data Center? Click here !

Info
titleAvailability

This routine is available starting with katl-commons SIL Engine™ 4.1.0.17

Syntax

fromJson(json)

Description

Excerpt

Converts the given JSON string into a SIL SIL™ type (can be a primitive, array or struct).

Parameters

Parameter name

Type

Required

Description

json

string

Yes

The JSON to be converted.

Return type

variable return type - depending on the left hand side operator type

Examples

Both examples show how JSON data can be parsed into an array or struct collections. Both examples use the following struct definitions:

Code Block
languagecpp
themeEclipse
linenumberstrue
struct code {
    number [] rgba;
    string hex;
}

struct color {
    string color;
    string category;
    string type;
    code code;
}

struct colors {
    color [] colors;
}

Example 1 - Reading JSON from a file

HttpHeader header
Code Block
languagecpp
themeEclipse
firstline16
linenumberstrue
string json = httpCreateHeader("Content-Type", "application/json")readFromTextFile("C:\\colors.json");


colors cData;
cData = fromJson(json);

return cData.colors[0].color;

Example 2 - Reading JSON from a variable

Code Block
languagecpp
themeEclipse
firstline16
linenumberstrue
string json = "{\"colors\":[{\"color\":\"red\",\"category\":\"hue\",\"type\":\"primary\",\"code\":{\"rgba\":[255,0,0,1],\"hex\":\"#FF0\"}}]}";

colors cData;
cData = fromJson(json);

return cData.colors[0].color;


See also

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
cqllabel = "http_support"
labelsjira_project_routine

...