definy.parse-json
- description
- Parse JSON text (numbers must be integers)
- type
Fn(text: String) -> Union{#ok(@definy.json), #error(String)}- expression
fn(text$0) => let source$1 = {text: $0, bytes: @core.string-to-bytes(value: $0)}; match @definy.json-parse-value(source: $1, index: 0) { #error(message$2) => #error($2), #ok(parsed$3) => let end$4 = @definy.text-skip(source: $1, index: $3.next); match @core.equal(left: $4, right: @core.list-length(value: $1.bytes)) { true => #ok($3.value), false => #error(@definy.text-error(message: "unexpected text after the JSON value", index: $4)) } }- visibility
- public
definy.parse-json (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo) id: SXWT2KrR1lZELMfdliXNnv2wP9QVoMpEzF8GXRY5Z7M content hash: rc_HiNUrxutcTeD29ivUsm1xbsamZOkLmBYFlWf6c44