Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get json key as value instead string with json_encode function use

I am trying to convert php array to json using
json_encode()

By using this I am getting
[{"s":"simple2","value":"simple2","i":"img","u":"url","p":"520.000000"}]

Instead of key as string I wants this data in below format
[{s:"simple2",value:"simple2",i:"img",u:"url",p:"520.000000"}]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How to get this type of data ? Is it possible to get this type data?

>Solution :

json_encode() will produce only a valid json format which is really the one it is producing. The one that you want is not a valid json format. You will have to apply text processing to get what you need. However, what is your final goal with the output of json array? Most languages that can can process json will accept the valid format.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading