Package jsonvalues.spec
Class JsObjParser
- java.lang.Object
-
- jsonvalues.spec.JsObjParser
-
public final class JsObjParser extends Object
-
-
Constructor Summary
Constructors Constructor Description JsObjParser(JsSpec spec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsObj
parse(byte[] bytes)
parses an array of bytes into a Json object that must conform the spec of the parser.JsObj
parse(InputStream inputstream)
parses an input stream of bytes into a Json object that must conform the spec of the parser.JsObj
parse(String str)
parses a string into a Json object that must conform the spec of the parser.
-
-
-
Constructor Detail
-
JsObjParser
public JsObjParser(JsSpec spec)
- Parameters:
spec
- the Json spec what defines the schema the json has to conform
-
-
Method Detail
-
parse
public JsObj parse(byte[] bytes)
parses an array of bytes into a Json object that must conform the spec of the parser. If the array of bytes doesn't represent a well-formed Json or is a well-formed Json that doesn't conform the spec of the parser, a ParsingException failure wrapped in a Try computation is returned.- Parameters:
bytes
- a Json object serialized in an array of bytes- Returns:
- a try computation with the result
-
parse
public JsObj parse(String str)
parses a string into a Json object that must conform the spec of the parser. If the string doesn't represent a well-formed Json or is a well-formed Json that doesn't conform the spec of the parser, a ParsingException failure wrapped in a Try computation is returned.- Parameters:
str
- a Json object serialized in a string- Returns:
- a try computation with the result
-
parse
public JsObj parse(InputStream inputstream)
parses an input stream of bytes into a Json object that must conform the spec of the parser. If the the input stream of bytes doesn't represent a well-formed Json object or is a well-formed Json that doesn't conform the spec of the parser, a ParsingException failure wrapped in a Try computation is returned. Any I/O exception processing the input stream is wrapped in a Try computation as well- Parameters:
inputstream
- the input stream of bytes- Returns:
- a try computation with the result
-
-