return; default: LOGGER.debug("Unexpected JSON toekn {}", token.toString()); break;
.addException(IOException.class); ClassName token = ClassName.get(JsonToken.NULL.getDeclaringClass());
@Override public PreviewObject read(JsonReader in) throws IOException { PreviewObject preview = new PreviewObject(); in.beginObject(); while (in.hasNext()) { String name = in.peek().toString(); if (!name.isEmpty()) { preview = readObject(in); } } in.endObject(); return preview; }
public ODataFeed readFeedStandalone() throws EntityProviderException { try { readFeed(); if (reader.peek() != JsonToken.END_DOCUMENT) { throw new EntityProviderException(EntityProviderException.END_DOCUMENT_EXPECTED.addContent(reader.peek().toString())); } } catch (IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e); } catch (EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e); } catch (IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e); } return new ODataFeedImpl(entries, feedMetadata); }
public Map<String, Object> readPropertyStandalone(final JsonReader reader, final EntityPropertyInfo propertyInfo, final EntityProviderReadProperties readProperties) throws EntityProviderException { Map<String, Object> typeMappings = readProperties == null ? null : readProperties.getTypeMappings(); Map<String, Object> result = new HashMap<String, Object>(); try { reader.beginObject(); String nextName = reader.nextName(); if (FormatJson.D.equals(nextName)) { reader.beginObject(); nextName = reader.nextName(); handleName(reader, typeMappings, propertyInfo, readProperties, result, nextName); reader.endObject(); } else { handleName(reader, typeMappings, propertyInfo, readProperties, result, nextName); } reader.endObject(); if (reader.peek() != JsonToken.END_DOCUMENT) { throw new EntityProviderException(EntityProviderException.END_DOCUMENT_EXPECTED.addContent(reader.peek() .toString())); } return result; } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
public Map<String, Object> readPropertyStandalone(final JsonReader reader, final EdmProperty property, final EntityProviderReadProperties readProperties) throws EntityProviderException { try { EntityPropertyInfo entityPropertyInfo = EntityInfoAggregator.create(property); Map<String, Object> typeMappings = readProperties == null ? null : readProperties.getTypeMappings(); Map<String, Object> result = new HashMap<String, Object>(); reader.beginObject(); String nextName = reader.nextName(); if (FormatJson.D.equals(nextName)) { reader.beginObject(); nextName = reader.nextName(); handleName(reader, typeMappings, entityPropertyInfo, result, nextName); reader.endObject(); } else { handleName(reader, typeMappings, entityPropertyInfo, result, nextName); } reader.endObject(); if (reader.peek() != JsonToken.END_DOCUMENT) { throw new EntityProviderException(EntityProviderException.END_DOCUMENT_EXPECTED.addContent(reader.peek().toString())); } return result; } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e); } catch (final IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e); } }
public Map<String, Object> readPropertyStandalone(final JsonReader reader, final EntityPropertyInfo propertyInfo, final EntityProviderReadProperties readProperties) throws EntityProviderException { Map<String, Object> typeMappings = readProperties == null ? null : readProperties.getTypeMappings(); Map<String, Object> result = new HashMap<String, Object>(); try { reader.beginObject(); String nextName = reader.nextName(); if (FormatJson.D.equals(nextName)) { reader.beginObject(); nextName = reader.nextName(); handleName(reader, typeMappings, propertyInfo, readProperties, result, nextName); reader.endObject(); } else { handleName(reader, typeMappings, propertyInfo, readProperties, result, nextName); } reader.endObject(); if (reader.peek() != JsonToken.END_DOCUMENT) { throw new EntityProviderException(EntityProviderException.END_DOCUMENT_EXPECTED.addContent(reader.peek() .toString())); } return result; } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
public ODataEntry readSingleEntry() throws EntityProviderException { try { reader.beginObject(); String nextName = reader.nextName(); if (FormatJson.D.equals(nextName)) { reader.beginObject(); readEntryContent(); reader.endObject(); } else { handleName(nextName); readEntryContent(); } reader.endObject(); if (reader.peek() != JsonToken.END_DOCUMENT) { throw new EntityProviderException(EntityProviderException.END_DOCUMENT_EXPECTED.addContent(reader.peek().toString())); } } catch (IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e); } catch (EdmException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e); } catch (IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e); } return entryResult; }
private Object getValue(JsonReader in) throws IOException { Object value = null; // if the next json token is a number we read it as a BigDecimal, // otherwise use the default adapter to read it if (JsonToken.NUMBER.equals(in.peek())) { value = new BigDecimal(in.nextString()); } else { value = valueAdapter.read(in); } return value; }
private static Map<String, String> toMapStr(String json) throws IOException { try (JsonReader in = new JsonReader(new StringReader(json))) { JsonToken token = in.peek(); if (token.equals(JsonToken.BEGIN_OBJECT)) { Map<String, String> map = new LinkedHashMap<>(); in.beginObject(); while (in.hasNext()) { map.put(in.nextName(), read2Str(in, true).toString()); } in.endObject(); return map; } return Collections.emptyMap(); } }
public Map<String, Object> readPropertyStandalone(final JsonReader reader, final EdmProperty property, final EntityProviderReadProperties readProperties) throws EntityProviderException { try { EntityPropertyInfo entityPropertyInfo = EntityInfoAggregator.create(property); Map<String, Object> typeMappings = readProperties == null ? null : readProperties.getTypeMappings(); Map<String, Object> result = new HashMap<String, Object>(); reader.beginObject(); String nextName = reader.nextName(); if (FormatJson.D.equals(nextName)) { reader.beginObject(); nextName = reader.nextName(); handleName(reader, typeMappings, entityPropertyInfo, result, nextName); reader.endObject(); } else { handleName(reader, typeMappings, entityPropertyInfo, result, nextName); } reader.endObject(); if (reader.peek() != JsonToken.END_DOCUMENT) { throw new EntityProviderException(EntityProviderException.END_DOCUMENT_EXPECTED.addContent(reader.peek() .toString())); } return result; } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
/** * For internal use only by data model classes */ @Override public UUID read( final JsonReader in ) throws IOException { if (in.peek().equals(JsonToken.NULL)) { in.nextNull(); return null; } final String jsonDateValue = in.nextString(); try { return EdmGuid.getInstance().valueOfString(jsonDateValue, EdmLiteralKind.JSON, null, UUID.class); } catch( final EdmSimpleTypeException e ) { return null; } }