All Bundles

JsonStreamParser

Event driven stream JSON parser

Operations

Code example:

stream := System.IO.Filesystem.FileReader->ReadFile(args[0]);
parser := Data.JSON.Stream.JsonStreamParser->New(stream);
if(parser->GetNextElement("person") & parser->GetNextElement("age") & parser->GetNextElement()) {
  parser->GetValue()->PrintLine();
};

parser->Reset();
while(parser->GetType() <> JsonStreamParser->JsonStreamType->END & parser->GetType() <> JsonStreamParser->JsonStreamType->ERROR) {
  if(parser->GetType() = JsonStreamParser->JsonStreamType->OBJECT_LIT) {
    if(parser->GetNextElement()) {
      parser->GetValue()->PrintLine();
    };
  };
};

New

Constructor

New()

Constructor

New(stream:String)
Parameters
NameTypeDescription
streamStringinput stream

GetLastError

Get the last error message

method : public : GetLastError() ~ String
Return
TypeDescription
Stringlast error message

GetLevel

Gets the current stream document tree level. 0 is the document root.

method : public : GetLevel() ~ Int
Return
TypeDescription
Intcurrent stream document tree level

GetNextElement

Gets the next element that matches the object literal name

method : public : native : GetNextElement(value:String) ~ Bool
Parameters
NameTypeDescription
valueStringvalue to match

Return
TypeDescription
Booltrue if element match, false otherwise

Gets the next element

method : public : GetNextElement() ~ Bool
Return
TypeDescription
Booltrue if successful match, false otherwise

Gets the nth element per offset

method : public : native : GetNextElement(offset:Int) ~ Bool
Parameters
NameTypeDescription
offsetIntoffset from current position

Return
TypeDescription
Booltrue if element match, false otherwise

GetType

Gets the current stream type

method : public : GetType() ~ JsonStreamParser->JsonStreamType
Return
TypeDescription
JsonStreamParser->JsonStreamTypecurrent stream type

GetTypeName

Gets the current stream type name

method : public : GetTypeName() ~ String
Return
TypeDescription
Stringcurrent stream type name

GetValue

Gets the current stream value

method : public : GetValue() ~ String
Return
TypeDescription
Stringcurrent stream value

More

Checks to see the element pointer can be advanced

method : public : More() ~ Bool
Return
TypeDescription
Booltrue if pointer can be advanced, false otherwise

Next

Advances the element pointer

method : public : Next() ~ Nil

Reset

Reset stream cursor to the beginning

method : public : Reset() ~ Nil

Reset stream cursor to the beginning and reset buffer

method : public : Reset(stream:String) ~ Nil
Parameters
NameTypeDescription
streamStringinput stream buffer