List of usage examples for com.google.gson.stream JsonToken BOOLEAN
JsonToken BOOLEAN
To view the source code for com.google.gson.stream JsonToken BOOLEAN.
Click Source Link
From source file:org.eclipse.skalli.core.rest.JSONRestReader.java
License:Open Source License
@Override public boolean isValue() throws IOException { if (state == STATE_FINAL) { return false; }/*w w w . ja va 2 s.co m*/ if (isKey("value")) { //$NON-NLS-1$ return true; } JsonToken next = json.peek(); return lookAhead == null && (next == JsonToken.STRING || next == JsonToken.NUMBER || next == JsonToken.BOOLEAN || next == JsonToken.BEGIN_ARRAY || next == JsonToken.BEGIN_OBJECT || next == JsonToken.NULL); }
From source file:org.immutables.gson.stream.JsonParserReader.java
License:Apache License
private static JsonToken toGsonToken(com.fasterxml.jackson.core.JsonToken token) { switch (token) { case START_ARRAY: return JsonToken.BEGIN_ARRAY; case END_ARRAY: return JsonToken.END_ARRAY; case START_OBJECT: return JsonToken.BEGIN_OBJECT; case END_OBJECT: return JsonToken.END_OBJECT; case FIELD_NAME: return JsonToken.NAME; case VALUE_FALSE: return JsonToken.BOOLEAN; case VALUE_TRUE: return JsonToken.BOOLEAN; case VALUE_NULL: return JsonToken.NULL; case VALUE_NUMBER_INT: return JsonToken.NUMBER; case VALUE_NUMBER_FLOAT: return JsonToken.NUMBER; case VALUE_STRING: return JsonToken.STRING; default: // Not semantically equivalent return JsonToken.NULL; }// www . ja v a2s. com }
From source file:org.immutables.mongo.bson4gson.BsonReader.java
License:Apache License
private static JsonToken toGsonToken(BsonType type) { switch (type) { case END_OF_DOCUMENT: return JsonToken.END_DOCUMENT; case DOCUMENT: return JsonToken.BEGIN_OBJECT; case ARRAY://from w ww . java 2 s . c om return JsonToken.BEGIN_ARRAY; case BOOLEAN: return JsonToken.BOOLEAN; case STRING: case SYMBOL: case OBJECT_ID: case BINARY: case REGULAR_EXPRESSION: return JsonToken.STRING; case DATE_TIME: case DOUBLE: case INT32: case INT64: case TIMESTAMP: case DECIMAL128: return JsonToken.NUMBER; case NULL: return JsonToken.NULL; default: // not really sure what to do with this type return JsonToken.NULL; } }
From source file:org.jetbrains.io.JsonReaderEx.java
License:Apache License
/** * Returns the type of the next token without consuming it. *///from w w w . j a v a 2 s . c o m public JsonToken peek() { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } switch (p) { case PEEKED_BEGIN_OBJECT: return JsonToken.BEGIN_OBJECT; case PEEKED_END_OBJECT: return JsonToken.END_OBJECT; case PEEKED_BEGIN_ARRAY: return JsonToken.BEGIN_ARRAY; case PEEKED_END_ARRAY: return JsonToken.END_ARRAY; case PEEKED_SINGLE_QUOTED_NAME: case PEEKED_DOUBLE_QUOTED_NAME: case PEEKED_UNQUOTED_NAME: return JsonToken.NAME; case PEEKED_TRUE: case PEEKED_FALSE: return JsonToken.BOOLEAN; case PEEKED_NULL: return JsonToken.NULL; case PEEKED_SINGLE_QUOTED: case PEEKED_DOUBLE_QUOTED: case PEEKED_UNQUOTED: case PEEKED_BUFFERED: return JsonToken.STRING; case PEEKED_LONG: case PEEKED_NUMBER: return JsonToken.NUMBER; case PEEKED_EOF: return JsonToken.END_DOCUMENT; default: throw new AssertionError(); } }
From source file:ru.orangesoftware.financisto2.export.flowzr.FlowzrSyncEngine.java
License:Open Source License
public <T> int readJsnArr(JsonReader reader, String tableName, Class<T> clazz) throws IOException, JSONException, Exception { JSONObject o = new JSONObject(); JsonToken peek = reader.peek();//from w w w.j a va2s . co m String n = null; reader.beginArray(); int j = 0; int i = 0; while (reader.hasNext()) { peek = reader.peek(); if (reader.peek() == JsonToken.BEGIN_OBJECT) { reader.beginObject(); } else if (reader.peek() == JsonToken.END_OBJECT) { reader.endObject(); } o = new JSONObject(); while (reader.hasNext()) { peek = reader.peek(); if (peek == JsonToken.NAME) { n = reader.nextName(); } else if (peek == JsonToken.BEGIN_OBJECT) { reader.beginObject(); } else if (peek == JsonToken.END_OBJECT) { reader.endObject(); } else if (peek == JsonToken.BOOLEAN) { try { o.put(n, reader.nextBoolean()); } catch (JSONException e) { e.printStackTrace(); } } else if (peek == JsonToken.STRING) { try { o.put(n, reader.nextString()); } catch (JSONException e) { e.printStackTrace(); } } else if (peek == JsonToken.NUMBER) { try { o.put(n, reader.nextDouble()); } catch (JSONException e) { e.printStackTrace(); } } } reader.endObject(); if (o.has("key")) { i = i + 1; j = j + 1; if (j % 100 == 0) { j = 2; } saveEntityFromJson(o, tableName, clazz, i); if (i % 10 == 0) { flowzrSyncActivity.notifyUser( flowzrSyncActivity.getString(R.string.flowzr_sync_receiving) + " " + tableName + ". " + flowzrSyncActivity.getString(R.string.hint_run_background), (int) (Math.round(j))); } } } reader.endArray(); return i; }