本文整理汇总了Java中com.google.gson.JsonIOException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java JsonIOException.getMessage方法的具体用法?Java JsonIOException.getMessage怎么用?Java JsonIOException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gson.JsonIOException
的用法示例。
在下文中一共展示了JsonIOException.getMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeInternal
import com.google.gson.JsonIOException; //导入方法依赖的package包/类
protected void writeInternal(Object o, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
Charset charset = this.getCharset(outputMessage.getHeaders());
OutputStreamWriter writer = new OutputStreamWriter(outputMessage.getBody(), charset);
try {
if(this.jsonPrefix != null) {
writer.append(this.jsonPrefix);
}
this.gson.toJson(o, writer);
writer.close();
} catch (JsonIOException var7) {
throw new HttpMessageNotWritableException("Could not write JSON: " + var7.getMessage(), var7);
}
}
示例2: writeInternal
import com.google.gson.JsonIOException; //导入方法依赖的package包/类
@Override
protected void writeInternal(Object o, Type type, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
Charset charset = getCharset(outputMessage.getHeaders());
try (OutputStreamWriter writer = new OutputStreamWriter(outputMessage.getBody(), charset)) {
if (ignoreType) {
gsonForWriter.toJson(o, writer);
return;
}
if (type != null) {
gsonForWriter.toJson(o, type, writer);
return;
}
gsonForWriter.toJson(o, writer);
} catch (JsonIOException ex) {
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
}
}
示例3: writeInternal
import com.google.gson.JsonIOException; //导入方法依赖的package包/类
@Override
protected void writeInternal(Object o, Type type, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
Charset charset = getCharset(outputMessage.getHeaders());
OutputStreamWriter writer = new OutputStreamWriter(outputMessage.getBody(), charset);
try {
if (this.jsonPrefix != null) {
writer.append(this.jsonPrefix);
}
if (type != null) {
this.gson.toJson(o, type, writer);
}
else {
this.gson.toJson(o, writer);
}
writer.close();
}
catch (JsonIOException ex) {
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
}
}
示例4: writeInternal
import com.google.gson.JsonIOException; //导入方法依赖的package包/类
@Override
protected void writeInternal(Object o, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
OutputStreamWriter writer = new OutputStreamWriter(outputMessage.getBody(), getCharset(outputMessage.getHeaders()));
try {
if (this.prefixJson) {
writer.append("{} && ");
}
Type typeOfSrc = getType();
if (typeOfSrc != null) {
this.gson.toJson(o, typeOfSrc, writer);
} else {
this.gson.toJson(o, writer);
}
writer.close();
} catch(JsonIOException ex) {
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
}
}
示例5: writeInternal
import com.google.gson.JsonIOException; //导入方法依赖的package包/类
@Override
protected void writeInternal( Object o, HttpOutputMessage outputMessage )
throws IOException, HttpMessageNotWritableException{
OutputStreamWriter writer = new OutputStreamWriter( outputMessage.getBody(), getCharset( outputMessage.getHeaders() ) );
try{
if( this.prefixJson ){
writer.append( "{} && " );
}
Type typeOfSrc = getType();
if( typeOfSrc != null ){
this.gson.toJson( o, typeOfSrc, writer );
}
else{
this.gson.toJson( o, writer );
}
writer.close();
}
catch( JsonIOException ex ){
throw new HttpMessageNotWritableException( "Could not write JSON: " + ex.getMessage(), ex );
}
}