gleam-lang / gleam-lang/json

I'd like a nicer api to create objects without null properties

Open
#32 4 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
Gleam
Stars
149
Forks
19
PR merge metrics
No merged PRs in 30d

Description

I often write the following
```rs
json.object([
#("foo", json.nullable(x, json.int)
])
```
Which will create `{foo: null}` when x is `None`. What I often want is `{}` when x is null several API's in the wild crash if an optional field is instead sent with a value of null.

A possible implementation was suggested in https://github.com/gleam-lang/json/pull/31 though it's not clear this is the best PR.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the object-building example in the issue and the proposed implementation in PR 31. Determine the API shape that best supports omitting optional fields whose values are None; done means non-null fields remain and null optional fields are omitted from the resulting object.

Written by the indexing model from the issue text.

Assessment

Tech stack
json
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.