@Test public void shouldDeserializeOnlyFirstJSONObject() throws Exception { String json = "{ name: \"parameter\" }\n" + "hello;hello"; BufferedReader reader = StringStreamUtil.reader(json); Parameter parameter = deserializer.deserialize(reader); assertThat(parameter).isNotNull().hasName("parameter"); assertThat(reader).hasTextLeft("\nhello;hello"); }
@Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; }
JsonParameterMetadataDeserializer implements ParameterMetadataDeserializer { @Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; } }
JsonParameterMetadataDeserializer implements ParameterMetadataDeserializer { @Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; } JsonParameterMetadataDeserializer(); }
JsonParameterMetadataDeserializer implements ParameterMetadataDeserializer { @Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; } JsonParameterMetadataDeserializer(); @Override AppendableParameter deserialize(BufferedReader reader); }
JsonParameterMetadataDeserializer implements ParameterMetadataDeserializer { @Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; } JsonParameterMetadataDeserializer(); @Override AppendableParameter deserialize(BufferedReader reader);  }