2

How can I ignore a key when using json.encode?

Something like this:

final map = json.decode(json.encode(routine), reviver: (key, value) {
      if (key == "id") {
        return null;
      }
      return value;
    });

But this way my map has a key id with value null. I want my map to not have the id key.

Any Idea?

Jonas
  • 7,089
  • 15
  • 49
  • 110

1 Answers1

1

You can remove the key.

routine.remove("id");
final map = json.decode(json.encode(routine));
janstol
  • 2,857
  • 1
  • 18
  • 21