1

Using QJson to parse this data:

"ShelveId": {
  "0": {
    "BeBoardId": {
      "0": {
        "connectionId": "board0", .... followed by more data

I'd like to traverse this table quicker than doing this. All maps are QVariantMaps:

map_BeBoardId = map_ShelveId["0"].toMap();

map_BeBoardId = map_BeBoardId["BeBoardId"].toMap();

auto temp = map_BeBoardId["0"].toMap();
m_connectionId = temp["connectionId"].toString();

qDebug() << m_connectionId;

Which works and returns me my connectionId "board0" correctly.

What I'd like to do instead is something like this:

map_BeBoardId = map_ShelveId["0"].toMap();

map_BeBoardId = map_BeBoardId["BeBoardId", "0"].toMap();

m_connectionId = map_BeBoardId["connectionId"].toString();

qDebug() << m_connectionId;

This returns me an empty connectionId.

And no, I can't use lists here as sometimes we may have a Shelve Id of "1" and "4" depending on what is connected.

Jason Fox
  • 5,115
  • 1
  • 15
  • 34
fiz
  • 906
  • 3
  • 14
  • 38

1 Answers1

0

For the weary traveller, after all sorts of attempts, this is what I came up with:

auto temp = map_BeBoardId.value("0").toMap().value("connectionId").toString();

A bit verbose, yes, anyone else come up with a better solution then then can post it.

fiz
  • 906
  • 3
  • 14
  • 38