String (Json function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
No edit summary
 
Line 1: Line 1:
{{Template:Json:String subtitle}}
{{Template:Json:String subtitle}}
 
This function creates a Json object of the string type.
This page is [[under construction]].
==Syntax==
==Syntax==
{{Template:Json:String syntax}}
{{Template:Json:String syntax}}
Line 8: Line 7:
<tr><th>%json</th><td><var>Json</var> object</td></tr>
<tr><th>%json</th><td><var>Json</var> object</td></tr>
<tr><th nowrap="true"><var>[%(Json):]</var></th>
<tr><th nowrap="true"><var>[%(Json):]</var></th>
<td>The optional class name in parentheses denotes a [[Notation conventions for methods#Constructors|virtual constructor]]. See [[#Usage notes|"Usage notes"]], below, for more information about invoking a virtual constructor.</td></tr>
<td>The optional class name in parentheses denotes a [[Notation conventions for methods#Constructors|virtual constructor]].</td></tr>
<tr><th>unicode</th>
<tr><th>unicode</th>
<td>Unicode</td></tr>
<td>The unicode value of the string Json object. EBCDIC strings are automatically converted to unicode.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<li>As with all virtual or true constructors, it is usually not necessary to specify the <code>%(json):</code> before the String method. That is <code>%json = %(json):string("foo")</code> is equivalent to <code>%json = string("foo")</code>. And, because of [[Json class#Implicit conversions|implicit conversion]] it is not even necessary to specify the String method so the previous could be written <code>%json = "foo"</code>.</li>
<li>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).</li>
</ul>
==Examples==
==Examples==
The following (silly) example, creates a Json string object whose value comes from a numeric variable:
<p class="code">b
%productCode is float
%json        is object json
%productCode = 74321
%json = string(%productCode)
printText {~=%json}
end
</p>
This prints:
<p class="code">%json="74321"
</p>
==See also==
==See also==
{{Template:Json:String footer}}
{{Template:Json:String footer}}

Latest revision as of 21:49, 18 February 2015

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