String (Json function)

From m204wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Create a String JSON object (Json class)

[Introduced in Model 204 7.6]

This function creates a Json object of the string type.

Syntax

%json = [%(Json):]String( unicode)

Syntax terms

%jsonJson object
[%(Json):] The optional class name in parentheses denotes a virtual constructor.
unicode The unicode value of the string Json object. EBCDIC strings are automatically converted to unicode.

Usage notes

  • As with all virtual or true constructors, it is usually not necessary to specify the %(json): before the String method. That is %json = %(json):string("foo") is equivalent to %json = string("foo"). And, because of implicit conversion it is not even necessary to specify the String method so the previous could be written %json = "foo".
  • The String method is probably most useful when its input value has a numeric type but semantically the value is a string (like a numeric product code).

Examples

The following (silly) example, creates a Json string object whose value comes from a numeric variable:

b %productCode is float %json is object json %productCode = 74321 %json = string(%productCode) printText {~=%json} end

This prints:

%json="74321"

See also