#reference #json #enums #json-object #single #value #string

jdt_maybe_reference

MaybeReference is a utility crate that establishes an enum to use where a value may either be a single JSON string or a JSON object

10 releases

0.1.9 Jan 22, 2025
0.1.8 Jan 22, 2025

#691 in Encoding

Download history 430/week @ 2024-12-29 254/week @ 2025-01-05 14/week @ 2025-01-12 443/week @ 2025-01-19 40/week @ 2025-01-26 17/week @ 2025-02-02

524 downloads per month
Used in 2 crates

MIT license

6KB
101 lines

MaybeReference

This is a utility crate that establishes an enum to use to match a JSON value that may be a single string (a "reference"), a reference in the form of {"id": "reference"} or an object.

"https://example.com/id/uuid"
{"id": "reference"}
{"id": "reference", "content": "somecontent"}

These would all match to MaybeReference<String> as ::Reference, ::Identifier, ::Actual, respectively.

Dependencies

~2.8–5MB
~89K SLoC