jeudi 13 février 2020

RapidJSON - using wildcards to iterate through complex JSON structures with different member names

I have a complex JSON to load into a data structure in C++11 and I got high recommendations about RapidJSON. I need to iterate over a complex JSON and looked around for answers on how to do it. The best answer I found was in this thread.

However, there's a small glitch in matching this solution to mine, I have members in the JSON that have different names but identical content:

"responsibilities": {
  "starters_reciepe": {
    "name": "bok choi salad",
    "type": "veggie",
    "ingredients": {
      "leafyIng": "bok choi",
      "proteinIng": "tofu",
      "seasoning": [
        {
          "2 tsp": "salt",
          "1 tsp": "turmric"
        }
      ]
    }
  },
  "mainCourse_reciepe": {
    "name": "pad tai",
    "type": "yum yum",
    "ingredients": {
      "leafyIng": "chard",
      "proteinIng": "soylent green"
      "seasoning": [
        {
          "2 tsp": "black pepper",
          "1 tsp": "tears of the angels"
        }
      ]
    }
}

}

Basically, I need to go over the content of the ingredients, but I can't get over the fact that starters_reciepe is not like mainCourse_reciepe.

Can I use wildcards and write *_reciepe?

I could find anything on RapidJSON and wildcards. Is this even a possibility?

Aucun commentaire:

Enregistrer un commentaire