Read JSON fields with ok/err, not some/none - #5
Merged
Conversation
Json accessors return result<T, string> now, so the wrong kind reports what it found instead of a bare none (muxlang/mux-compiler#404). The example benefits from the change it is tracking: "status is not an int" becomes a message saying what the field actually held. Needs a compiler with that change to run.
|
| Filename | Overview |
|---|---|
| examples/http_server/main.mux | Updates string and integer JSON field accessors to handle result values and return the detailed accessor error; the previously discarded diagnostic is now preserved. |
Reviews (2): Last reviewed commit: "Pass the accessor error through instead ..." | Re-trigger Greptile
The err arms returned the old generic <not a string> / <not an int>, so the example converted to ok/err without showing what the conversion is FOR - a wrong-typed field still printed a message that says nothing about what was there. The accessor now reports 'expected a string, found an int', so that is what the example prints. Caught in review.
This was referenced Aug 21, 2026
DerekCorniello
added a commit
to muxlang/mux-website-api
that referenced
this pull request
Aug 21, 2026
The image pulls the release tarball for this version, so this cannot be deployed until v0.10.0 is tagged in mux-compiler. Merging it early is fine; building it early is not. 0.10.0 is what the docs are written against: muxlang/mux-website#59 and muxlang/mux-examples#5 are both red purely because they compile against the released compiler, which still has optional accessors and no from_json.
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.
Jsonaccessors returnresult<T, string>now, so the wrong kind reports what it found instead of a barenone(muxlang/mux-compiler#404).The example benefits from the change it was written to track:
status is not an intbecomes a message saying what the field actually held.Needs a compiler with that change to run, so hold until the release ships.