Pretty new to JavaScript, JSON, and web development in general. But I'm trying to parse a large amount of frame data from a game in JSON. I had the information in a JSON file but I can't find a way to import the data to have it usable in my JavaScript file.
Instead I have it being parsed from JSON text inside of my JavaScript file. I don't like this because I can't put line breaks in my IDE (VSCode) without it erroring the JSON text. It has to be a whole straight line and there's a lot of data.
It just doesn't look clean and I'd rather be able to do it with normal JSON formatting from the file. I'll include some examples so you guys can see what I mean:
const nameJson = '{"Name": "name", "Jab1": 2, "Jab1_OS": -14, "Jab2": 2, "Jab2_OS": -16, "Jab3": 3, "Jab3_OS": -29, "Ftilt": 5, "Ftilt_OS": -13, "Uptilt": 5, "Uptilt_OS": -18, "Dtilt": 5, "Dtilt_OS": -15, "Fair": 16,"Fair_OS": -12,"UpB": 3,"UpB_OS": -20,"Bair": 6,"Bair_OS": -2,"Dair": 5,"Dair_OS": -11,"Upair": 4,"Upair_OS": -3}'
const name= JSON.parse(nameJson);
What I would like it to look like is:
[
{
"Name": "Name1",
"Fair": 16,
"Fair_OS": -12,
"UPB": 3,
"UPB_OS": "-99"
},
{
"Name": "Name2",
"Fair": 14,
"FairOS": -7,
"UPB": 14,
"UPB_OS": "-99"
}
]
Even if there's a way to make it formatted that way in the .js file I'm working in I'd like that answer too.
Thanks!