Intro / What I Tried
I'm trying to parse JSON files (which I've never done before). I first tried JsonCpp using this tutorial:
https://www.codeproject.com/Articles/1102603/Accessing-JSON-Data-with-Cplusplus#_articleTop
But Json::Reader is deprecated and didn't seem to work.
I then tried looking into nlohmann's Parser which is nice because it only requires 1 header file to include:
https://github.com/nlohmann/json/tree/v3.6.1#stl-like-access
But I couldn't figure out how to get it to work. It gives errors when I include the header file as seen here:
https://github.com/nlohmann/json/issues/1659
Then I looked into how to create my own JSON parser and as I'm sure you can guess, that was insanely difficult (for a beginner). :P
So... After spending ~4 days trying to figure this out, now I'm here.
What I am trying to do:
There's a game called Minecraft that is Survival based and allows you to craft different items and build or use them for various things.
In short, I'm trying to parse the data and store the data into my program.
Here's an example JSON file -
acacia_boat.json
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
{
"type": "crafting_shaped",
"group": "boat",
"pattern": [
"# #",
"###"
],
"key": {
"#": {
"item": "minecraft:acacia_planks"
}
},
"result": {
"item": "minecraft:acacia_boat"
}
}
|
Another Example -
piston.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
{
"type": "crafting_shaped",
"pattern": [
"TTT",
"#X#",
"#R#"
],
"key": {
"R": {
"item": "minecraft:redstone"
},
"#": {
"item": "minecraft:cobblestone"
},
"T": {
"tag": "minecraft:planks"
},
"X": {
"item": "minecraft:iron_ingot"
}
},
"result": {
"item": "minecraft:piston"
}
}
|
https://minecraft.gamepedia.com/Recipe#JSON_format
How can I parse the data and print it in my program?
Thanks!
Please Note: I may take 1-4 days to respond because I'm going to be very busy with a school project. But I'll check this when I can!
Edit: Apologies, this project is taking much longer than I expected.. I'll read and respond to all replies when I can. I'm going to be swamped for the week though as the semester is nearing the end.