public final class ToScalaCollection<A> extends Object implements JSONParseListener
This does not care a lot about errors in the JSON source - it will create a Pair and put that in an array if it happens to find a colon in a JSONArray for example - but if there is nested arrays, the decoder may have a problem with invalid JSONObjects - in fact the default one does.
Constructor and Description |
---|
ToScalaCollection(JSONDecoder<A> decoder) |
Modifier and Type | Method and Description |
---|---|
boolean |
abort()
returns whether the parsing can end at this time
|
static ToScalaCollection<Object> |
apply()
Returns a ToScalaCollection using a ToScalaCollectionJSONDecoder
|
static <A> ToScalaCollection<A> |
apply(JSONDecoder<A> decoder) |
void |
charRead(int index,
char charact)
A character has been read
|
JSONDecoder<A> |
decoder() |
void |
elemEnded(int index,
char charact)
An element has ended
|
void |
elemStarted(int index,
char charact)
An element has started
|
void |
ended()
Called when the parsing ends.
|
void |
endingBracket(int index,
char charact)
The level has changed
|
void |
keyValueSeparation(int index,
char charact)
A key has ended and a value has started
|
void |
openingBracket(int index,
char charact)
Indicates that the initial bracket has been reached
|
scala.collection.immutable.Seq<scala.util.Either<A,scala.Tuple2<String,A>>> |
result()
Returns the parsed result.
|
scala.collection.immutable.Map<String,A> |
resultMap()
Returns the parsed result converted to a Map.
|
scala.collection.immutable.Seq<A> |
resultSeq()
Returns the parsed result converted to a Seq.
|
void |
started()
Called when the parsing starts.
|
public ToScalaCollection(JSONDecoder<A> decoder)
public static ToScalaCollection<Object> apply()
public static <A> ToScalaCollection<A> apply(JSONDecoder<A> decoder)
public JSONDecoder<A> decoder()
public boolean abort()
JSONParseListener
abort
in interface JSONParseListener
public void charRead(int index, char charact)
JSONParseListener
charRead
in interface JSONParseListener
index
- the index of the charactercharact
- the read characterpublic void started()
JSONParseListener
started
in interface JSONParseListener
public void ended()
JSONParseListener
ended
in interface JSONParseListener
public void elemStarted(int index, char charact)
JSONParseListener
elemStarted
in interface JSONParseListener
index
- the index of the commacharact
- the character that started the elementpublic void openingBracket(int index, char charact)
JSONParseListener
openingBracket
in interface JSONParseListener
index
- the location of the bracketcharact
- the bracket characterpublic void endingBracket(int index, char charact)
JSONParseListener
endingBracket
in interface JSONParseListener
index
- the location of the changecharact
- the character used in the changepublic void elemEnded(int index, char charact)
JSONParseListener
elemEnded
in interface JSONParseListener
index
- the index of the commacharact
- the character that ended the elementpublic void keyValueSeparation(int index, char charact)
JSONParseListener
keyValueSeparation
in interface JSONParseListener
index
- the index of the commacharact
- the character that split the elementpublic scala.collection.immutable.Seq<scala.util.Either<A,scala.Tuple2<String,A>>> result()
public scala.collection.immutable.Seq<A> resultSeq()