M
M
Maxim Severukhin2015-08-10 14:05:08
PHP
Maxim Severukhin, 2015-08-10 14:05:08

How to fix incorrect json string?

In a table cell there is a line with data in the form of a json string. Ex:
"\u0410\u0431\u043e\u043d\u0435\u043d\u0442"
But it was not preserved correctly. Ex:
u0410u0431u043eu043du0435u043du0442
Forgot to put JSON_UNESCAPED_UNICODE before saving the string
.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
localghost, 2015-08-10
@maksim_sev

Please clarify, should all "u" ​​be replaced with "\u" or something more complicated?
Upd .:
I’ll take it out of the comment so that it’s clear if anyone else needs it:
If one line cannot have both, then the lines with which everything is in order are eliminated through where, and the replacement can be done through set field = replace(field, 'u', '\\u'). I'm not sure about the double slash, check it out.

R
Rsa97, 2015-08-10
@Rsa97

Use mysqli_ or PDO prepared queries

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question