google / cel-spec

Common Expression Language -- specification and binary representation
https://cel.dev
Apache License 2.0
2.67k stars 216 forks source link

Map to Map/List conversion #248

Open zhqu1148980644 opened 1 year ago

zhqu1148980644 commented 1 year ago

The spec says map/filter macro only support list type, how to apply map/filter macros to map, so we can transform a map to another map or list.

expected use case:

  1. map to list
    
    {
    "k1": "v1",
    "k2": "v2"
    }.map({k, v}, {k: v})

==>

[ {"k1": "v1"}, {"k2": "v2"} ]


2. list to map

map([ ["k1", "v1"], ["k2": "v2"] ])

==> { "k1": "v1", "k2": "v2" }