Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LiteralMapExpression needs support for collection-if expression #447

Open
lukehutch opened this issue Jan 3, 2024 · 0 comments
Open

LiteralMapExpression needs support for collection-if expression #447

lukehutch opened this issue Jan 3, 2024 · 0 comments

Comments

@lukehutch
Copy link

LiteralMapExpression does not yet support collection-if. This means it's not possible to generate the following:

{
  if (x != null) 'x' : x,
  if (y != null) 'y': y,
  if (z != null) 'z': z,
}

I need to be able to add these conditions in order to minimize the text-rendered size of sparse JSON maps.

Presumably the way to support this would be similar to how literalSpread works:

literalMap({
  collectionIf(refer('x').isNotNull(), 'x'): refer('x'),
  // ...
})

Expression.visitLiteralMapExpression will also need to be updated to support this (and it should work for sets and lists too)..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant