@Test(expected = JsonParseException.class) public void deserialize_NotJsonObject() throws JsonProcessingException, IOException { when(jsonParser.getCurrentToken()).thenReturn(JsonToken.VALUE_STRING); deserializer.deserialize(jsonParser, dContext); }
@Override public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (!JsonToken.START_OBJECT.equals(jp.getCurrentToken()) && !JsonToken.START_ARRAY.equals(jp.getCurrentToken())) { throw new JsonParseException("tag value is not a json object or array", jp.getCurrentLocation()); } return jp.readValueAsTree().toString(); }
JsonObjectToStringDeserializer extends StdScalarDeserializer<String> { @Override public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (!JsonToken.START_OBJECT.equals(jp.getCurrentToken()) && !JsonToken.START_ARRAY.equals(jp.getCurrentToken())) { throw new JsonParseException("tag value is not a json object or array", jp.getCurrentLocation()); } return jp.readValueAsTree().toString(); } }
JsonObjectToStringDeserializer extends StdScalarDeserializer<String> { @Override public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (!JsonToken.START_OBJECT.equals(jp.getCurrentToken()) && !JsonToken.START_ARRAY.equals(jp.getCurrentToken())) { throw new JsonParseException("tag value is not a json object or array", jp.getCurrentLocation()); } return jp.readValueAsTree().toString(); } JsonObjectToStringDeserializer(); }
JsonObjectToStringDeserializer extends StdScalarDeserializer<String> { @Override public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (!JsonToken.START_OBJECT.equals(jp.getCurrentToken()) && !JsonToken.START_ARRAY.equals(jp.getCurrentToken())) { throw new JsonParseException("tag value is not a json object or array", jp.getCurrentLocation()); } return jp.readValueAsTree().toString(); } JsonObjectToStringDeserializer(); @Override String deserialize(JsonParser jp, DeserializationContext ctxt); }
JsonObjectToStringDeserializer extends StdScalarDeserializer<String> { @Override public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (!JsonToken.START_OBJECT.equals(jp.getCurrentToken()) && !JsonToken.START_ARRAY.equals(jp.getCurrentToken())) { throw new JsonParseException("tag value is not a json object or array", jp.getCurrentLocation()); } return jp.readValueAsTree().toString(); } JsonObjectToStringDeserializer(); @Override String deserialize(JsonParser jp, DeserializationContext ctxt);  }