How to parse the JSON that its field name has no double quote in PHP
Here is an example of such a JSON that I received….
[{meta_data: [{name: "HANDLE", value: "2"}], compound: { name: "Numeric", entries: [{meta_data: [{name: "partition", value: "2"}, {name: "metric-id", value: "18474"}, {name: "unit-code", value: "2720"}, {name: "unit", value: "bpm"}], simple: {name: "Basic-Nu-Observed-Value", type: "float", value: "72.000000"}}, {compound: { name: "Absolute-Time-Stamp", entries: [{simple: {name: "century", type: "intu8", value: "20"}}, {simple: {name: "year", type: "intu8", value: "12"}}, {simple: {name: "month", type: "intu8", value: "4"}}, {simple: {name: "day", type: "intu8", value: "11"}}, {simple: {name: "hour", type: "intu8", value: "3"}}, {simple: {name: "minute", type: "intu8", value: "10"}}, {simple: {name: "second", type: "intu8", value: "26"}}, {simple: {name: "sec_fractions", type: "intu8", value: "0"}}] }}] }}]
Manually since its not valid JSON without the “. If the requirements state that the data is to be exchanged in JSON format then its not really your problem its the app/person supplying the JSON that has the issue. Push back at them and have them fix the issue on their end.
Bear Says:
Ok then you need to fix the part of the app generating the JSON, not necesarily the part consuming it (assuming youre using the standard
json_decodeon the consumption side). If thats the case your inital question really become irrelevant and you may or may not need to post a new question on how best to go about reworking the code to generate proper JSON.