Repository navigation
codec: Decoded replaces the JSON value type - #281
Merged
Merged
Conversation
#257 (unreleased) made the type named JSON an untyped value held as JSON text, which put format special cases in the checker, materialization, equality, enum literal checks, List.join, the encoder and ScalarValue (isJSONScalar, jsonKey). Decoded now names data of any shape without belonging to a format, so the JSON value type goes: JSON is a plain namespace like YAML and TOML (and Random). `:: JSON` code moves to `:: Decoded!` (or a schema's own scalar, `Dagger.JSON`), and String-to-JSON casts to `JSON.decode(s)`. The lit docs drop the "Data of unknown shape" section (its cases are covered by #decoded-values) and point its references there.
Deploying dang with
|
| Latest commit: |
74ead6d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7937b984.dang-3kk.pages.dev |
| Branch Preview URL: | https://decoded-replaces-json.dang-3kk.pages.dev |
A directive's argument types were resolved in the applying file's scope, so an imported schema's or Dang module's `@meta(level: Level)` read `Level` as whatever that file binds to the name (its own enum, or a builtin such as the JSON namespace) rather than the declaring module's type. Directives now remember the scope they are declared in (a schema's, or the one a Dang declaration is hoisted into) and resolve argument types there. Signed-off-by: Alex Suraci <[email protected]>
Ports the cases of the removed JSON value tests that no Decoded test covered: JSON.encode options inside Decoded data, strict decoding around a Decoded field, TOML into Decoded, and toString/join of collections holding it. Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
decoded-replaces-json
branch
from
November 9, 2026 15:43
6e59af4 to
d3bb2eb
Compare
This was referenced Nov 9, 2026
The codec pages and skill references explained Decoded by the JSON value
type it replaces ("No JSON value type", "hold functions, not data", "Dang
has no JSON value type of its own") and carried a migration note. Describe
the current types instead: Decoded holds data of any shape, JSON is the
codec namespace, and a schema's scalar JSON is an ordinary schema scalar.
Drop JSON from the examples of custom GraphQL scalars, since unqualified it
names the namespace.
Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
decoded-replaces-json
branch
from
November 9, 2026 21:47
d3bb2eb to
2cf0dfa
Compare
The strict-decoding section said a Decoded value takes any key, without the catch the decoded-values section states: a later cast of data from a strict decode is strict too. Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
decoded-replaces-json
branch
from
November 9, 2026 22:13
f2dc2d9 to
80d9679
Compare
With the JSON value type gone, the name JSON names the codec namespace in both namespaces, so its members list like Random's and the lookup of a name's separate value namespace has nothing left to find. Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
decoded-replaces-json
branch
2 times, most recently
from
November 9, 2026 22:46
447f59c to
74ead6d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes the untyped
JSONvalue type that #257 added (merged after v2.3.0, so not yet released). Data of unknown shape is nowDecoded, a type you can name. With this PR,JSON,YAMLandTOMLare all just codec namespaces, and no format has special cases in the type checker, materialization, equality,List.join, the encoder orScalarValue.What changes
codec: replace the JSON value type with Decoded).isJSONScalar,isJSONValueandisJSONNullValue, and every special case they guarded:materializeDecoded;List.join;ScalarValue.jsonKeyandJSONType.materialize.goloses about 180 lines.JSONis a plain namespace likeYAML/TOML(andRandom), andjsonCodecisCodec{JSONModule}. There is no namespace-specific check or error: written as a type,JSON!names the namespace's own type, asRandom!does.:: JSON!becomes:: Decoded!, and"text" :: JSON!becomesJSON.decode("text") :: Decoded!.scalar JSON(Dagger.JSON) is unchanged: it is a plain schema scalar.directives: resolve arg types where declared).directive @meta(level: Level)typedlevelin the applying file's scope. There,Levelmay be the file's own type, or a builtin such as theJSONnamespace.{#decoded-values}section, and every reference now points there.Decodedinstead of the JSON value.JSON.decodedoc no longer claims to take a JSON value.analysislistsJSON's members as it listsRandom's (TestDocOfStatics), now that the nameJSONis only the namespace.test_json_value.dangis deleted.Decodedtest covered are ported totest_decoded_encode.dang:Decodedfield;toString/join.json_cast_invalid,json_literal_not_json) go with the feature.Maintainer decisions
Decoded(first-class, opaque) replaces codec: make JSON an untyped JSON value #257's JSON value type. That type is unreleased, so this change needs no deprecation path.isJSONScalaras it was on main. This PR removes the type, soisJSONScalarand every identity check that went with it are gone.x: JSON!named a builtin JSON scalar. It now names theJSONnamespace, likeRandom!, so such code fails with a generic type error (cannot use String! as JSON!). WriteDecoded!for data of any shape (JSON.decode(text) :: Decoded!), orDagger.JSON!(a schema's own scalar) for the server's JSON values.Testing
dang fmt, goldens reviewed, and every check (**) passes.TestRunDirImportedDirectiveArgsUseSchemaTypesandTestRunDirImportedNativeDirectiveArgsUseModuleTypes(both fail without the directive fix).test_decoded_encode.