D
D
Denis2020-04-30 12:53:38
PHP
Denis, 2020-04-30 12:53:38

What is the best way to organize work with json?

Getting familiar with the json format. I emulate the situation. Instead of a database file with json. Now every function for working with data always starts with json_decode at the input, and is the json_encode return normal? The data that on any should be converted here and there. I just wonder if there is another way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Neverov, 2020-04-30
@TTATPuOT

In PHP, you can only convert JSON to an array or object using json_decode. And convert from PHP to JSON only through json_encode.
What exactly are your concerns?

V
Vadym Masiuk, 2020-04-30
@7TyLe

Yes, this is absolutely normal. JSON was invented for this - to transfer information.
If the data is PHP oriented, I recommend using serialize() instead of json_encode(). There are small bonuses in terms of working with objects that are lost when using json_encode ().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question