JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line
原创
©著作权归作者所有:来自51CTO博客作者IT路宇的原创作品,请联系作者获取转载授权,否则将追究法律责任
问题场景:
当时在做数据上传的时候,遇到的。
最后发现问题的所在,在提交数据到API中时,我当时只上传了一条数据,用户的提交意见,而数据表中的其他数据,没有进行上传,比如用户ID,phone…
凡是数据列表中,存在的成员变量,都要给其赋值,才能成功上传数据,即使你用到的数据,只有其中的几条。
在实体类中,赋值ID,和当前时间,可以直接赋值
AlarmRecordID= UUID.randomUUID().toString();
DiagnosticTime=DateUtil.getNowDateTime("yyyy-MM-dd HH:mm:ss");
CreateDate=DateUtil.getNowDateTime("yyyy-MM-dd HH:mm:ss");
ModifyDate=DateUtil.getNowDateTime("yyyy-MM-dd HH:mm:ss");
在上传时,赋值… 数据全部要赋值,不能为空
case R.id.btn_submit_opinion:
SoundAlarmRecord soundAlarmRecord=new SoundAlarmRecord();
soundAlarmRecord.Diagnostic=edit_diagnostic_opinion.getText().toString();
soundAlarmRecord.DiagnosticUser=this.phone;
soundAlarmRecord.SoundPointCode=this.SoundPointCode;
soundAlarmRecord.IsDiagnostic="1";
soundAlarmRecord.IsSendMsg="0";
soundAlarmRecord.IsSoundAlarm="0";
soundAlarmRecord.IsTempAlarm="0";
soundAlarmRecord.Creator=this.phone;
soundAlarmRecord.Modifier=this.phone;
if (TextUtils.isEmpty(soundAlarmRecord.Diagnostic)){
Toast.makeText(RecordplayActivity.this, "提交诊断意见不能为空!", Toast.LENGTH_SHORT).show();
}else {
SubmittextFile(soundAlarmRecord);
btn_submit_opinion.setEnabled(false);
}
在这里记录一下,有同样问题的可以参考借鉴…