E
E
error 4042019-02-17 17:45:49
PHP
error 404, 2019-02-17 17:45:49

How to use json file?

There is an index.json file and if you
find task in the address bar /?task=1, there is a link in it and paste it as a link to the image
(How to attach a file?)
Part of the code:

"task":{"title":"1","title_short":"1","description":"","youtube_video_id":"","url":"\/po-algebre\/7-klass\/alimov\/1"},"editions":[{"title":"решебник","description":"","type":2,"publisher_id":2,"texts":[],"images":[{"title":"","url":"https:\/\/gdz-ru.com\/attachments\/images\/tasks\/000\/049\/432\/0002\/5929bcd75c180.jpg"}]}]}

And there are a lot of such tasks in the file
link to the file

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
Fedor Rychkov, 2019-02-17
@StonedCatt

in the address bar you will most likely have /task?id=1 using some js urlencoder or react-router ... etc, depending on what you use, you can take the id parameter from the address bar, make a request using the library for requests, for example axios and pull out your index.json using the get method, filter the array of tasks by id and pull out the object of the desired task. Next, take the url and insert the img element with src=task.url into the DOM. If you have React / Angular / Vue, this will not be difficult, but if you have jQuery / Vanilla, then you will have to describe DOM manipulations.

D
Dmitry, 2019-02-17
@Compolomus

$json = '{"task":{"title":"1","title_short":"1","description":"","youtube_video_id":"","url":"\/po-algebre\/7-klass\/alimov\/1"},"editions":[{"title":"решебник","description":"","type":2,"publisher_id":2,"texts":[],"images":[{"title":"","url":"https:\/\/gdz-ru.com\/attachments\/images\/tasks\/000\/049\/432\/0002\/5929bcd75c180.jpg"}]}]}';

$arr = json_decode($json, true);

echo $arr['editions'][0]['images'][0]['url'];

#echo '<pre>' . print_r($arr, true) . '</pre>';

D
dlakazov, 2019-02-17
@dlakazov

json is a file database, in the form of a key => value, if you parse an array, then there is nothing else in json,
[0 => 'fddf',2 => 'fddffd'] in json {"0":"dffd" , "2":"fdfddf"}, if you knew js, then everything would be clear, since its syntax is like that of a js object

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question