I am working on an Arduino project that will mix cocktails for me. I've decided to save a list of cocktails in a JSON file named cocktails.json, which is saved on an SD card, and upon cocktail selection, I would like the Arduino to find its recipe in the JSON file. A small snippet of the JSON looks like this:
{
"Cocktails": {
"Americano": {
"campari": 1
"red vermouth": 2
"soda": 3
},
"Aviation": {
"gin": 1,
"cherry liqueur": 2,
"creme de violette": 3,
"lemon juice": 4
},
"B52 Cocktail": {
"kahlua": 1,
"baileys": 2,
"trand marnier": 3
}
}
}
Say I tell the Arduino I want the cocktail "Americano". I would like the Arduino to copy all the data under object "Americano" and save it to a 2D array I created in the following struct:
struct cocktailData
{
char name[25];
char portions[7][1];
} data;
The array is initialized as [7][1] because there are up to 8 potential ingredients and they're all paired with an amount multiplier. I can't figure out how to copy the entire string into the array so that it saves the recipe in memory. Im using the ArduinoJson library to parse the JSON file. The end goal is that the array would look something like this:
portions[0-7][0]=
"campari", "red vermouth", "soda", (the rest is null)
portions[0-7][1]=
1, 2, 3, (the rest is null)