#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

7 releases

new 0.1.6 Jan 5, 2025
0.1.5 Jan 4, 2025

#562 in Encoding

Download history 637/week @ 2025-01-01

637 downloads per month
Used in jdt_activity_pub

MIT license

5KB
86 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

~3–5MB
~90K SLoC