So, basically i have a JSON file
{"date":"2020-01-25","explanation":"In this Hubble Space Telescope image the bright, spiky stars lie in the foreground toward the heroic northern constellation Perseus and well within our own Milky Way galaxy. In sharp focus beyond is UGC 2885, a giant spiral galaxy about 232 million light-years distant. Some 800,000 light-years across compared to the Milky Way's diameter of 100,000 light-years or so, it has around 1 trillion stars. That's about 10 times as many stars as the Milky Way. Part of a current investigation to understand how galaxies can grow to such enormous sizes, UGC 2885 was also part of astronomer Vera Rubin's pioneering study of the rotation of spiral galaxies. Her work was the first to convincingly demonstrate the dominating presence of dark matter in our universe.","hdurl":"https://apod.nasa.gov/apod/image/2001/RubinsGalaxy_hst2000.jpg","media_type":"image","service_version":"v1","title":"Rubin's Galaxy","url":"https://apod.nasa.gov/apod/image/2001/RubinsGalaxy_hst1024.jpg"}
It's a NASA APOD Api. I want to get that one particular "hdurl" value and set it as a URL Variable inside batch: "https://apod.nasa.gov/apod/image/2001/RubinsGalaxy_hst2000.jpg"
Then i want it to download the image from that site.
I honestly have no idea how i'm supossed to do it. Any help will be very appreciated!
You can use 2 time the for loop:
1st delimiters :}
in for
loop, and ;
(default) in 2nd for
loop 2nd:
for /f tokens^=4*delims^=^:^} %i in ('type file.json')do for /f tokens^=1delims^=^"^ %I in ('echo/%i%j')do echo/%I && set "_imageURL=%I"
@echo off
for /f tokens^=4*delims^=^:^} %%i in ('type file.json
')do for /f tokens^=1delims^=^"^ %%I in ('echo/%%i%%j')do echo/%%I && set "_imageURL=%%I"
https//apod.nasa.gov/apod/image/2001/RubinsGalaxy_hst2000.jpg
{"date":"2020-01-25","explanation":"In this Hubble Space Telescope image the bright, spiky stars lie in the foreground toward the heroic northern constellation Perseus and well within our own Milky Way galaxy. In sharp focus beyond is UGC 2885, a giant spiral galaxy about 232 million light-years distant. Some 800,000 light-years across compared to the Milky Way's diameter of 100,000 light-years or so, it has around 1 trillion stars. That's about 10 times as many stars as the Milky Way. Part of a current investigation to understand how galaxies can grow to such enormous sizes, UGC 2885 was also part of astronomer Vera Rubin's pioneering study of the rotation of spiral galaxies. Her work was the first to convincingly demonstrate the dominating presence of dark matter in our universe.","hdurl":"https://apod.nasa.gov/apod/image/2001/RubinsGalaxy_hst2000.jpg","media_type":"image","service_version":"v1","title":"Rubin's Galaxy","url":"https://apod.nasa.gov/apod/image/2001/RubinsGalaxy_hst1024.jpg"}