Problem/Motivation
Say you have map item field on a custom entity with value ['foo' => 'bar']
You can filter by using ?filter[my_field]=a%3A1%3A%7Bs%3A3%3A%22foo%22%3Bs%3A3%3A%22bar%22%3B%7D
Which is ['foo' => 'bar'] serialized and url encoded.
This works like a charm, since Map field values are saved as serialized arrays to the database.
However it's not very JSON:API like.
Proposed resolution
Not hampered by any in-depth knowledge of the JSON API spec or technical consequences, I would like to suggest to to allow Map Item values to be filtered using Json encoding instead of serializing.
E.g.
?filter[my_field]=%7B%22foo%22%3A%22bar%22%7D
Which is {"foo":"bar"} but url encoded.
(Or ?filter[my_field.foo]=bar ? )
Comments
Comment #2
wim leersAh, yes, this makes sense. This is a consequence of the design of the
@FieldType=mapfield type plugin combined with the design of the Entity Query API. There's not really something JSON:API can do about this, we'll need to fix this in Drupal core itself. I'll find an existing core issue and link to that or create a new core issue.