Object -
io
:
StringReader
Represents a reader which will wrap string content as a channel.
Constructor
__init
(string content, string encoding)
- content string
-
The content, which should be written
- encoding string UTF-8
-
Encoding of the characters of the content
Methods
Reads string as JSON using the reader.
io:StringReader reader = new("{\"name\": \"Alice\"}");
json|io:Error? person = reader.readJson();
Reads a string as XML using the reader.
io:StringReader reader = new("<Person><Name>Alice</Name></Person>");
xml|io:Error? person = reader.readXml();
Reads the characters from the given string.
io:StringReader reader = new("Some text");
string|io:Error? person = reader.readChar(4);
Closes the reader.
io:Error? err = reader.close();
Reads string as JSON using the reader.
io:StringReader reader = new("{\"name\": \"Alice\"}");
json|io:Error? person = reader.readJson();
-
Return Type
(json | Error) JSON or else
io:Error
if any error occurred
Reads a string as XML using the reader.
io:StringReader reader = new("<Person><Name>Alice</Name></Person>");
xml|io:Error? person = reader.readXml();
-
Return Type
(xml | Error | ()) XML or else
io:Error
if any error occurred
Reads the characters from the given string.
io:StringReader reader = new("Some text");
string|io:Error? person = reader.readChar(4);
Parameters
- nCharacters int
-
Number of characters to be read
-
Return Type
(string | Error | ()) String or else
io:Error
if any error occurred