@Override public Object parse(String json) throws InvalidJsonException { try { return objectMapper.readTree(json); } catch (IOException e) { throw new InvalidJsonException(e, json); } }
@Override public Object parse(String json) throws InvalidJsonException { try { return objectReader.readValue(json); } catch (IOException e) { throw new InvalidJsonException(e, json); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { return objectMapper.readTree(new InputStreamReader(jsonStream, charset)); } catch (IOException e) { throw new InvalidJsonException(e); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { return objectReader.readValue(new InputStreamReader(jsonStream, charset)); } catch (IOException e) { throw new InvalidJsonException(e); } }
@Override public String toJson(Object obj) { StringWriter writer = new StringWriter(); try { JsonGenerator generator = objectMapper.getFactory().createGenerator(writer); objectMapper.writeValue(generator, obj); writer.flush(); writer.close(); generator.close(); return writer.getBuffer().toString(); } catch (IOException e) { throw new InvalidJsonException(e); } }
@Override public Object parse(String json) throws InvalidJsonException { try { return new JSONTokener(json).nextValue(); } catch (JSONException e) { throw new InvalidJsonException(e); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { return new JSONTokener(new InputStreamReader(jsonStream, charset)).nextValue(); } catch (UnsupportedEncodingException e) { throw new JsonPathException(e); } catch (JSONException e) { throw new InvalidJsonException(e); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int size; while( (size=jsonStream.read(buffer))>0 ) { stream.write(buffer, 0, size); } return parse(new JettisonTokener(new String(stream.toByteArray(), charset))); } catch( IOException ioe ) { throw new InvalidJsonException(ioe); } }
public Object parse(String json) { try { return createParser().parse(json, mapper); } catch (ParseException e) { throw new InvalidJsonException(e); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { return createParser().parse(new InputStreamReader(jsonStream, charset), mapper); } catch (ParseException e) { throw new InvalidJsonException(e); } catch (UnsupportedEncodingException e) { throw new JsonPathException(e); } }
@Override public Object parse(String json) throws InvalidJsonException { try { return objectReader.readValue(json); } catch (IOException e) { throw new InvalidJsonException(e, json); } }
@Override public Object parse(String json) throws InvalidJsonException { try { return objectMapper.readTree(json); } catch (IOException e) { throw new InvalidJsonException(e, json); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { return objectMapper.readTree(new InputStreamReader(jsonStream, charset)); } catch (IOException e) { throw new InvalidJsonException(e); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { return objectReader.readValue(new InputStreamReader(jsonStream, charset)); } catch (IOException e) { throw new InvalidJsonException(e); } }
@Override public String toJson(Object obj) { StringWriter writer = new StringWriter(); try { JsonGenerator generator = objectMapper.getFactory().createGenerator(writer); objectMapper.writeValue(generator, obj); writer.flush(); writer.close(); generator.close(); return writer.getBuffer().toString(); } catch (IOException e) { throw new InvalidJsonException(); } }
@Override public Object parse(String json) throws InvalidJsonException { try { return new JSONTokener(json).nextValue(); } catch (JSONException e) { throw new InvalidJsonException(e); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { return new JSONTokener(new InputStreamReader(jsonStream, charset)).nextValue(); } catch (UnsupportedEncodingException e) { throw new JsonPathException(e); } catch (JSONException e) { throw new InvalidJsonException(e); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int size; while( (size=jsonStream.read(buffer))>0 ) { stream.write(buffer, 0, size); } return parse(new JettisonTokener(new String(stream.toByteArray(), charset))); } catch( IOException ioe ) { throw new InvalidJsonException(ioe); } }
public Object parse(String json) { try { return createParser().parse(json, mapper); } catch (ParseException e) { throw new InvalidJsonException(e); } }
@Override public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException { try { return createParser().parse(new InputStreamReader(jsonStream, charset), mapper); } catch (ParseException e) { throw new InvalidJsonException(e); } catch (UnsupportedEncodingException e) { throw new JsonPathException(e); } }