【发布时间】:2021-04-05 21:44:58
【问题描述】:
我正在尝试解码以下 json 字符串,当我 var_dump 或 print_r 时,没有 json_decode 的字符串可以找到,但使用 decode 它打印 null 或 empty。下面是我的字符串
$xml ='{"pages":"3","results":"[{"row_id":1,"object_id":46740,"created_on":1608736483367,"title":"Q By Sikander","description":"description changed for edting","subject":"Mathematics","creator":"Sikander. nawaz ","object_lightbox_io":"<mxGraphModel dx="1165" dy="727" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0" /><mxCell id="1" parent="0" ><object label="" Name="question" id="winxapanwzodgiu_0"><mxCell style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;rounded=wrap;deletable=wrap;spacingLeft=10;spacingTop=30;strokeWidth=1;glass=0;comic=0;shadow=0;movable=1;resizable=1;strokeColor=#E6E6E6;fillColor=#FFFFFF;cloneable=0;rotatable=0;editable=1;recursiveResize=1;connectable=0;fontSize=12;fontFamily=Verdana;container=1;collapsible=0;spacing=10;allowArrows=0;expand=0;" parent="1" vertex="1"><mxGeometry x="40" y="40" width="750" height="339" as="geometry" ></mxCell></object><mxCell id="winxapanwzodgiu_1" value="Question" style="rounded=0;whiteSpace=wrap;html=1;strokeColor=none;fillColor=#E8E8E8;fontSize=16;fontStyle=1;align=left;spacing=14;connectable=0;allowArrows=0;recursiveResize=0;expand=0;editable=1;movable=0;resizable=0;rotatable=0;cloneable=0;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry width="150" height="30" as="geometry" /></mxCell><mxCell id="RJBhnMlJpycuwUT1BXIT-1" value="Text" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="381" y="58" width="40" height="20" as="geometry" /></mxCell><mxCell id="m-3Kp1ptq76vWhSLRoxc-1" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="273" y="160" width="80" height="80" as="geometry" /></mxCell><mxCell id="xlPOsWBx98iv5f53EXYo-1" value="" style="shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="111" y="222" width="120" height="80" as="geometry" /></mxCell><mxCell id="xlPOsWBx98iv5f53EXYo-2" value="" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="471" y="240" width="120" height="80" as="geometry" /></mxCell><mxCell id="xlPOsWBx98iv5f53EXYo-3" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="214" y="90" width="80" height="80" as="geometry" /></mxCell></root></mxGraphModel>"},{"row_id":2,"object_id":48747,"created_on":1608854400000,"title":"Updated Question ","description":"description changed for edting","subject":"Mathematics","creator":"Sikander. nawaz ","object_lightbox_io":"<mxGraphModel dx="810" dy="631" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0" /><mxCell id="1" parent="0" /><object label="" Name="question" id="winxapanwzodgiu_0"><mxCell style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;rounded=wrap;deletable=wrap;spacingLeft=10;spacingTop=30;strokeWidth=1;glass=0;comic=0;shadow=0;movable=1;resizable=1;strokeColor=#E6E6E6;fillColor=#FFFFFF;cloneable=0;rotatable=0;editable=1;recursiveResize=1;connectable=0;fontSize=12;fontFamily=Verdana;container=1;collapsible=0;spacing=10;allowArrows=0;expand=0;" parent="1" vertex="1"><mxGeometry x="40" y="40" width="750" height="339" as="geometry" /></mxCell></object><mxCell id="winxapanwzodgiu_1" value="Question" style="rounded=0;whiteSpace=wrap;html=1;strokeColor=none;fillColor=#E8E8E8;fontSize=16;fontStyle=1;align=left;spacing=14;connectable=0;allowArrows=0;recursiveResize=0;expand=0;editable=1;movable=0;resizable=0;rotatable=0;cloneable=0;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry width="150" height="30" as="geometry" /></mxCell><mxCell id="RJBhnMlJpycuwUT1BXIT-1" value="Text" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="381" y="58" width="40" height="20" as="geometry" /></mxCell><mxCell id="m-3Kp1ptq76vWhSLRoxc-1" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="273" y="160" width="80" height="80" as="geometry" /></mxCell><mxCell id="xlPOsWBx98iv5f53EXYo-1" value="" style="shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="111" y="222" width="120" height="80" as="geometry" /></mxCell><mxCell id="xlPOsWBx98iv5f53EXYo-2" value="" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="471" y="240" width="120" height="80" as="geometry" /></mxCell><mxCell id="xlPOsWBx98iv5f53EXYo-3" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="winxapanwzodgiu_0" vertex="1"><mxGeometry x="214" y="90" width="80" height="80" as="geometry" /></mxCell></root></mxGraphModel>"}]"}';
如果我删除 object_lightbox_io 内容并尝试根据整个字符串对字符串进行 2 次解码,然后根据结果索引对其进行解码,因此 object_lightbox_io 会出现问题请帮我解决这个问题,花了几个小时但无法解决它
【问题讨论】:
-
object_lightbox_io的值包含未转义的引号。这个 JSON 是如何生成的? -
我不确定它是如何生成的,通过 API 调用获得
-
你能帮忙解决这个问题吗?修复未转义的引号以对问题进行排序
-
试图解决这个问题似乎真的是一团糟,最好和产生这个问题的人谈谈,他们需要解决它。
-
如果我尝试在线解码它工作正常不知道它是如何工作的