[{
"id": 685509210310,
"intention_id": 13042,
"cuit": "133423122",
"branch": "Local",
"checkout": "7",
"establishment_id": "21312",
"transaction_datetime": "2021-03-10T17:07:10",
"payment_method_id": 1,
"payment_method_code": "VI",
"payment_method_type": "credit_card",
"card_data": {
"card_brand": "Visa",
"bin": "1211111",
"last_four_digits": "0000",
"bank_data": {
"id": 1,
"description": "Banco"
}
},
"amount": 1200.00,
"currency": "ARS",
"installments": 1,
"status": "approved",
"status_details": {
"card_authorization_code": "11111",
"card_reference_number": " 00000",
"response": {
"type": "approved",
"reason": {
"id": 0,
"description": "APROBADA (authno)",
"ticket_footer": "INFO ADICIONAL "
}
}
},
"terminal_data": {
"trace_number": 43,
"ticket_number": 121,
"terminal_number": "87212121"
}
}
]
强制转换的方法是
Collection read = new ObjectMapper().readValue(new_salida, new TypeReference<Collection>() {});
我不认为它会像你想要的那样起作用
这是应该走的路
Collection<YourObject> read = new ObjectMapper().readValue(new_salida, YourObject[].class);
和yourobject
必须定义,以便它能够保存您期望的json的值
> {
> "id":685509210310,
> "intention_id":13042,
> "cuit":"133423122",
> "branch":"Local",
> "checkout":"7",
> "establishment_id":"21312",
> "transaction_datetime":"2021-03-10T17:07:10",
> "payment_method_id":1,
> "payment_method_code":"VI",
> "payment_method_type":"credit_card",
> "card_data":{
> "card_brand":"Visa",
> "bin":"1211111",
> "last_four_digits":"0000",
> "bank_data":{
> "id":1,
> "description":"Banco"
> }
> },
> "amount":1200.00,
> "currency":"ARS",
> "installments":1,
> "status":"approved",
> "status_details":{
> "card_authorization_code":"11111",
> "card_reference_number":" 00000",
> "response":{
> "type":"approved",
> "reason":{
> "id":0,
> "description":"APROBADA (authno)",
> "ticket_footer":"INFO ADICIONAL "
> }
> }
> },
> "terminal_data":{
> "trace_number":43,
> "ticket_number":121,
> "terminal_number":"87212121"
> } }
我正在尝试发布一个自定义对象的。请求体中的JSON如下所示: 处理请求的服务器端代码: 实体: 但会引发异常:
下面是我的JSON响应, 原因:com.fasterxml.jackson.databind.JSONMappingException:无法反序列化[source:java.io.pushbackInputStream@bce1d9;行:1,列:556]处START_OBJECT标记外的java.util.ArrayList实例(通过引用链:com.totalhours[“data”]->com.
问题内容: 我正在尝试发布自定义对象。我在请求正文中的JSON是这样的: 处理请求的服务器端代码: 实体: 但是抛出一个异常: 问题答案: 问题是JSON-默认情况下不能反序列化为,因为它实际上不是JSON数组-看起来像这样: 由于你没有控制反序列化的确切过程(RestEasy确实如此)- 第一个选择是简单地将JSON作为a注入String,然后控制反序列化过程: 你不必自己进行操作便会失去一些便
发送帖子后,我收到400错误 响应为: 当我试图反序列化我的json数据时,我得到了一个异常。如何正确地反序列化JSON? 比尔·恩蒂蒂的文件是: BillController类中处理POST请求的控制器 最后,我的支付实体类:
问题内容: 我有一个休息终点,它返回。我正在尝试将此其余端点测试为 该测试失败,错误提示 如何解决此问题? 问题答案: 这看起来像杰克逊(Jackson)错误,它期望解析一个数组(以“ [”开头),但遇到一个对象(“ {”)的开头标记。通过查看您的代码,我猜测它正在尝试将JSON反序列化到您的List中,但它正在获取对象的JSON。 您的REST端点返回的JSON是什么样的?它应该看起来像这样
编辑: 我希望响应到我的logcat中,并在Imageview中获取图像