We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suggested transformation:
type Fruit = enum Banana, Apple Bar = object case kind: Fruit of Banana: bad: float banana: int of Apple: apple: string proc initFromJson(dst: var Bar; tree: JsonTree; n: NodePos) = verifyJsonKind(tree, n, {JObject}) var kindTmp: Fruit initFromJson(kindTmp, tree, rawGet(tree, n, "kind")) dst = (typeof dst)(kind: kindTmp) for x in keys(tree, n): case dst.kind of Banana: case x.str of "bad": initFromJson(dst.bad, tree, x.firstSon) of "banana": initFromJson(dst.banana, tree, x.firstSon) else: discard of Apple: case x.str of "apple": initFromJson(dst.apple, tree, x.firstSon) else: discard let x = parseJson("""{"kind":"Apple","apple":"world"}""") var b: Bar initFromJson(b, x, rootNodeId) echo b
The text was updated successfully, but these errors were encountered:
This is needlessly complicated due to recursive RecList. Let's wait until sum types land.
Sorry, something went wrong.
No branches or pull requests
suggested transformation:
The text was updated successfully, but these errors were encountered: