Java Code Examples for com.google.gson.stream.JsonReader#nextString()
The following examples show how to use
com.google.gson.stream.JsonReader#nextString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSON.java From influxdb-client-java with MIT License | 6 votes |
@Override public java.sql.Date read(JsonReader in) throws IOException { switch (in.peek()) { case NULL: in.nextNull(); return null; default: String date = in.nextString(); try { if (dateFormat != null) { return new java.sql.Date(dateFormat.parse(date).getTime()); } return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); } catch (ParseException e) { throw new JsonParseException(e); } } }
Example 2
Source File: SentryEnvelopeHeaderAdapter.java From sentry-android with MIT License | 6 votes |
@Override public SentryEnvelopeHeader read(JsonReader reader) throws IOException { if (reader.peek() == JsonToken.NULL) { reader.nextNull(); return null; } SentryId eventId = null; reader.beginObject(); while (reader.hasNext()) { switch (reader.nextName()) { case "event_id": eventId = new SentryId(reader.nextString()); break; default: reader.skipValue(); break; } } reader.endObject(); return new SentryEnvelopeHeader(eventId); }
Example 3
Source File: ExamplesManifest.java From r2m-plugin-android with Apache License 2.0 | 6 votes |
public ExamplesManifest(String json) throws IOException { this.examples = new HashMap<String, ExampleResource>(); JsonReader reader = new JsonReader(new StringReader(json)); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); // single example reader.beginObject(); String file = null; String description = null; while (reader.hasNext()) { String key = reader.nextName(); if (key.equals(FILE_KEY)) { file = reader.nextString(); } else if (key.equals(DESCRIPTION_KEY)) { description = reader.nextString(); } } reader.endObject(); examples.put(name, new ExampleResource(name, file, description)); } }
Example 4
Source File: JSON.java From director-sdk with Apache License 2.0 | 6 votes |
@Override public java.sql.Date read(JsonReader in) throws IOException { switch (in.peek()) { case NULL: in.nextNull(); return null; default: String date = in.nextString(); try { if (dateFormat != null) { return new java.sql.Date(dateFormat.parse(date).getTime()); } return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); } catch (ParseException e) { throw new JsonParseException(e); } } }
Example 5
Source File: JSON.java From oxd with Apache License 2.0 | 5 votes |
@Override public LocalDate read(JsonReader in) throws IOException { switch (in.peek()) { case NULL: in.nextNull(); return null; default: String date = in.nextString(); return LocalDate.parse(date, formatter); } }
Example 6
Source File: JsonLdSerializer.java From schemaorg-java with Apache License 2.0 | 5 votes |
private Thing readObject(JsonReader reader) throws IOException { reader.beginObject(); Multimap<String, ValueType> properties = LinkedListMultimap.create(); ListMultimap<String, Thing> reverseMap = LinkedListMultimap.create(); String typeName = null; while (reader.hasNext()) { String key = reader.nextName(); if (JsonLdConstants.TYPE.equals(key)) { typeName = reader.nextString(); } else if (JsonLdConstants.CONTEXT.equals(key)) { properties.putAll(key, readContext(reader)); } else if (JsonLdConstants.REVERSE.equals(key)) { reverseMap.putAll(readReverse(reader)); } else { properties.putAll( key, readInternal(reader, JsonLdConstants.ID.equals(key) /* acceptNull */)); } } reader.endObject(); if (Strings.isNullOrEmpty(typeName)) { // Treat any unrecognized types as Thing. typeName = THING; } // Value of @type should be short type name or full type name. // Doesn't support relative IRI or compact IRI for now. return buildSchemaOrgObject(typeName, properties, reverseMap); }
Example 7
Source File: TypeAdapters.java From framework with GNU Affero General Public License v3.0 | 5 votes |
@Override public String read(JsonReader in) throws IOException { JsonToken peek = in.peek(); if (peek == JsonToken.NULL) { in.nextNull(); return null; } /* coerce booleans to strings for backwards compatibility */ if (peek == JsonToken.BOOLEAN) { return Boolean.toString(in.nextBoolean()); } return in.nextString(); }
Example 8
Source File: Deployment.java From director-sdk with Apache License 2.0 | 4 votes |
@Override public JavaInstallationStrategyEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return JavaInstallationStrategyEnum.fromValue(String.valueOf(value)); }
Example 9
Source File: CharacterContractsResponse.java From eve-esi with Apache License 2.0 | 4 votes |
@Override public AvailabilityEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return AvailabilityEnum.fromValue(value); }
Example 10
Source File: CharacterMedalsResponse.java From eve-esi with Apache License 2.0 | 4 votes |
@Override public StatusEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return StatusEnum.fromValue(value); }
Example 11
Source File: ResourceMember.java From influxdb-client-java with MIT License | 4 votes |
@Override public RoleEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return RoleEnum.fromValue(String.valueOf(value)); }
Example 12
Source File: CorporationRolesResponse.java From eve-esi with Apache License 2.0 | 4 votes |
@Override public RolesAtBaseEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return RolesAtBaseEnum.fromValue(value); }
Example 13
Source File: HealthCheck.java From director-sdk with Apache License 2.0 | 4 votes |
@Override public HealthStatusEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return HealthStatusEnum.fromValue(String.valueOf(value)); }
Example 14
Source File: User.java From influxdb-client-java with MIT License | 4 votes |
@Override public StatusEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return StatusEnum.fromValue(String.valueOf(value)); }
Example 15
Source File: InstrumentName.java From v20-java with MIT License | 4 votes |
@Override public InstrumentName read(JsonReader in) throws IOException { return new InstrumentName(in.nextString()); }
Example 16
Source File: DashboardColor.java From influxdb-client-java with MIT License | 4 votes |
@Override public TypeEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return TypeEnum.fromValue(String.valueOf(value)); }
Example 17
Source File: OrderID.java From v20-java with MIT License | 4 votes |
@Override public OrderID read(JsonReader in) throws IOException { return new OrderID(in.nextString()); }
Example 18
Source File: ConfigurationProperty.java From director-sdk with Apache License 2.0 | 4 votes |
@Override public WidgetEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return WidgetEnum.fromValue(String.valueOf(value)); }
Example 19
Source File: ValidationExceptionCondition.java From director-sdk with Apache License 2.0 | 4 votes |
@Override public TypeEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return TypeEnum.fromValue(String.valueOf(value)); }
Example 20
Source File: Capabilities.java From director-sdk with Apache License 2.0 | 4 votes |
@Override public JavaVendorEnum read(final JsonReader jsonReader) throws IOException { String value = jsonReader.nextString(); return JavaVendorEnum.fromValue(String.valueOf(value)); }