A
A
Arseniy Sokolovsky2020-09-09 23:19:01
JavaScript
Arseniy Sokolovsky, 2020-09-09 23:19:01

How to get SRC path from JSON?

Hello, in short, I have JSON

{
      "time": 25526,
      "duration": 369,
      "url": "/maps/AintMy/pictos/picto-1.png",
      "isLineEnding": 0
    }


and <img id="pict" class="pict" src="">
as you can see there is an empty src there. How can I take the url from JSON and put it in src img ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Steppp, 2020-09-09
@SokolarGm

I could be wrong, but it's true!

const object = '{
      "time": 25526,
      "duration": 369,
      "url": "/maps/AintMy/pictos/picto-1.png",
      "isLineEnding": 0
    }';
console.log( JSON.parse(object.url));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question