8000 Exclude key using filter · Issue #1628 · bblanchon/ArduinoJson · GitHub
[go: up one dir, main page]

Skip to content
Exclude key using filter #1628
@dmadison

Description

@dmadison

Hello,

I'm wondering if it's possible to exclude a specific key in a filter rather than explicitly including all of the others.

For context, I have a JSON response I'm trying to parse that has a large array of strings I don't need. I'd like to keep the other ~15 keys, but it's a pain to keep track of every other key and mark each of those keys explicitly as "true" in the filter rather than marking one key as "false".

Here's a minimal sample of the JSON data:

{
  "data": [
    {
      "id": "123456789",
      "name": "John",
      "started_at": "2021-08-12T19:54:18Z",
      "language": "en",
      "tag_ids": [
        "ffb3744956f39b69bafd777c75efe3d3",
        "dbbc7932c63c7a3776a7bc0c6f7696f1",
        "cbc69d36b95b3d083fa78707bf4d67df",
        "a3d0a2b834bda602fdd962f0f84c6210",
        "26677562c8d68ce512f0ddc4d8390c69",
        "dc816b81f3c4524a42838698859efbb6",
        "f145b3b9d0567f41e658aa19d1c3fc65",
        "2f173d6ef410aa016a40ffba3b11bf88",
        "6f389ef6e9c811144b5efc63abbf83c9",
        "fa4bb4e69607560b6007710f175dd302"
      ]
    }
  ]
}

And here's my current filter, using a wildcard:

{
  "data": [
    {
      "*": true,
      "tag_ids": false
    }
  ]
}

The Assistant successfully filters out the "tag_ids" key, but the library on platform does not. I did not find any documentation using "false" values, so my guess is that this is not currently a supported feature.

I'm testing an ESP8266 (Wemos D1 Mini Lite) using Arduino 1.8.13. Here's the current C++ code:

StaticJsonDocument<96> filter;
filter["data"][0]["*"] = true;
filter["data"][0]["tag_ids"] = false;
StaticJsonDocument<2000> doc;
deserializeJson(doc, json, DeserializationOption::Filter(filter));

Thanks for any advice!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugv6ArduinoJson 6

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0