A
A
ashfedor2021-01-14 18:28:30
JSON
ashfedor, 2021-01-14 18:28:30

How to fix encoding in json Laravel?

I decided to try to work with api in Laravel I
deployed it in Laragona, I created a database with utf8mb4_unicode_ci encoding I
created two rest controllers for products and categories, set up a simple admin panel and fill the database in the usual way
Then I made a controller for output through the API
in it a method

public function index()
    {
      $products = $this->productRepositiry->getAllProducts();
      $data = json_decode($products, JSON_THROW_ON_ERROR);

//dd( $data);
      return $data;
    }

when I look through dd ()
all the rules
60006244d6229708870763.jpeg
and when in the json request then there are troubles with the Cyrillic encoding,
600062d2ca61d705896903.jpeg
can anyone tell me how to fix it? maybe json_decode is not spelled correctly

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2021-01-14
@JhaoDa

You need to start with the basics: read a little about JSON, understand that these are not “troubles”, then a little about json_encodethe PHP dock and learn about the available type constants-parameters JSON_UNESCAPED_UNICODE.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question