【发布时间】:2019-02-16 21:16:27
【问题描述】:
我知道这是无效的 json,但我从 creditswitch api 得到这个 json 作为响应,我无法更改这个响应,但我想解析这个 json
当我替换这个只是详细信息时,就像
desired json response
{
"statusCode": "00",
"statusDescription": {
"customerNo": 283375350,
"accountStatus": "OPEN",
"firstname": "ADVENTURE",
"lastname": "MOBILE",
"customerType": "SUD",
"invoicePeriod": 1,
"dueDate": "2018-09-29T00:00:00+01:00"
}
}
我得到了有效的 json,但是如何删除 json 的第一部分,我不知道任何解决方案,下面是我得到的原始 json。
this is the original json response
{
"details": {
"number": "10553886499",
"requestType": "VALIDATE_DEVICE_NUMBER"
},
"serviceId": "AQA"
}
{
"statusCode": "00",
"statusDescription": {
"customerNo": 283375350,
"accountStatus": "OPEN",
"firstname": "ADVENTURE",
"lastname": "MOBILE",
"customerType": "SUD",
"invoicePeriod": 1,
"dueDate": "2018-09-29T00:00:00+01:00"
}
}
【问题讨论】:
-
这样的简单检测会起作用吗?
$validJsonParts = explode("}\n{",$invalidJson);? -
"我知道这是无效的 json" 在哪里?
-
你的问题不清楚!!你从 API 中得到了哪个 JSON?然后告诉我们你想把它转换成什么
-
@kerbholz JSON的第二位无效,它在对象之间缺少
, -
请查看更新后的问题