DBEX Archive
A JSON-compatible encoder and decoder in Python built on generators, so it can stop at a chosen depth and hand back the rest lazily. On PyPI since 11th grade.
- Role
- Author
- Period
- 2020–2021
- Team
- Solo
- Stack
- Python · Cython
- Impact
- On PyPI as dbex

What I did
I wanted Python's json module, but made of generators. DBEX decodes and encodes JSON, and from a depth you choose it stops building values and hands back generators instead, so the deeper parts are read only when you need them. I published it on PyPI in 11th grade.
How it works
max_depthsets the cut: the decoder returns plain values above it and generator objects (list_gen,dict_gen,tuple_gen) below it; the encoder stays a generator down to the same depth.- Besides JSON it reads a few Python literals, such as tuples and
None. - An encryption step can be plugged into the stream.
- I also tried a Cython build of the decoder for speed.
import dbex
dec = dbex.Decoder(default_max_depth=0)
enc = dbex.Encoder(default_max_depth=0)
# with max_depth 0 these work like json.loads and json.dumps
data = dec.loads('["DBEX", [12, [3.4], 5.66], 7, null]')
text = enc.dumps(data)

