I
I
Ilya Rodionov2018-02-23 13:25:56
PHP
Ilya Rodionov, 2018-02-23 13:25:56

How to decode json in php?

Guys, please help. I broke my head and don't know what to do.
The fact is that the database stores a string in json format (?), but I don’t know how to decode it.
I connect via php to the mysql database where the string is stored, then I try to decode it using the standard json_decode method, but nothing happens.
A string in this format:

{"date-add-wl":{"field":{"id":3,"form_id":1,"priority":0,"type":"text","label":"\u0414\u0430\u0442\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0432\u0430\u0439\u0442\u043b\u0438\u0441\u0442","slug":"date-add-wl","options":[],"data":{"value":[],"data":[],"classSfx":"","help_text":"","help_show":"","hasOptions":0,"placeholder":"dd-mm-yyyy","multiple":0,"controls":null,"repeatable":null,"required":true,"requiredError":"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0434\u0430\u0442\u0443"},"roles":[3],"value":[],"valuedata":[],"formatted":["-"]},"slug":"date-add-wl","type":{"id":"text","label":"Textfield","hasOptions":0,"required":-1,"multiple":0,"placeholder":""},"label":"\u0414\u0430\u0442\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0432\u0430\u0439\u0442\u043b\u0438\u0441\u0442","
value":["\u0425\u0443\u0439\u0444"],"
formatted":["-"],"data":[],"field_id":3},"nick":{"field":{"id":4,"form_id":1,"priority":1,"type":"text","label":"\u041d\u0438\u043a \u043d\u0430

In principle, it is not so much important for me to decode everything, but one line after value":[... (I specially highlighted it with spaces in the code) value":["\u0425\u0443\u0439\u0444"] .
Tell me, please, how can I do this? I broke my head ...
UPD: here is what is in the data line in phpmyadmin
5a8fec72cdec9197178399.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-02-23
@ZloyKishechnik

json_decode Walk through
the received decoded objects in this way:
$json_decode->date-add-wl->field->data->and so on

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question