本文整理匯總了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 );
}
}