A
A
atis //2016-12-12 15:13:46
PHP
atis //, 2016-12-12 15:13:46

How to display JSON with Cyrillic in PHP?

Typical json:

{
  "id": 1,
  "name": "Жора"
}

It needs to be displayed on the screen in a readable way. Trouble occurs with Cyrillic, as it is encoded.
Example for JSON_PRETTY_PRINT.
<?= json_encode(['id' => 1, "name" => "Женя"], JSON_PRETTY_PRINT) ?>

{
    "id": 1,
    "name": "\u0416\u0435\u043d\u044f"
}

Lib did not find a case for this. There was only an example with str_replace.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rastishka, 2016-12-12
@atis2345

<?= json_encode(['id' => 1, "name" => "Женя"], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) ?>

A
axeax, 2016-12-12
@axeax

if the file encoding is utf8, it should work like that

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question