String (Json function)

From m204wiki
Revision as of 21:49, 18 February 2015 by Alex (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Create a String JSON object (Json class)

[Introduced in Model 204 7.6]

This function creates a Json object of the string type.


%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).


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:


See also