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
fromJson
bring http; bring cloud; struct Pokemon { id: str; name: str; order: num; weight: num; } new cloud.Function(inflight () => { let x = http.get("https://pokeapi.co/api/v2/pokemon/ditto"); // response status log(x.status); let data = Json.parse(x.body); // Cast response back into struct let ditto = Pokemon.fromJson(data); log(ditto.name); });
https://www.winglang.io/play/?code=YgByAGkAbgBnACAAaAB0AHQAcAA7AAoAYgByAGkAbgBnACAAYwBsAG8AdQBkADsACgAKAHMAdAByAHUAYwB0ACAAUABvAGsAZQBtAG8AbgAgAHsACgAgACAAaQBkADoAIABzAHQAcgA7AAoAIAAgAG4AYQBtAGUAOgAgAHMAdAByADsACgAgACAAbwByAGQAZQByADoAIABuAHUAbQA7AAoAIAAgAHcAZQBpAGcAaAB0ADoAIABuAHUAbQA7AAoAfQAKAAoAbgBlAHcAIABjAGwAbwB1AGQALgBGAHUAbgBjAHQAaQBvAG4AKABpAG4AZgBsAGkAZwBoAHQAIAAoACkAIAA9AD4AIAB7AAoAIAAgAGwAZQB0ACAAeAAgAD0AIABoAHQAdABwAC4AZwBlAHQAKAAiAGgAdAB0AHAAcwA6AC8ALwBwAG8AawBlAGEAcABpAC4AYwBvAC8AYQBwAGkALwB2ADIALwBwAG8AawBlAG0AbwBuAC8AZABpAHQAdABvACIAKQA7AAoACgAgACAALwAvACAAcgBlAHMAcABvAG4AcwBlACAAcwB0AGEAdAB1AHMACgAgACAAbABvAGcAKAB4AC4AcwB0AGEAdAB1AHMAKQA7AAoACgAgACAAbABlAHQAIABkAGEAdABhACAAPQAgAEoAcwBvAG4ALgBwAGEAcgBzAGUAKAB4AC4AYgBvAGQAeQApADsACgAKACAAIAAvAC8AIABDAGEAcwB0ACAAcgBlAHMAcABvAG4AcwBlACAAYgBhAGMAawAgAGkAbgB0AG8AIABzAHQAcgB1AGMAdAAKACAAIABsAGUAdAAgAGQAaQB0AHQAbwAgAD0AIABQAG8AawBlAG0AbwBuAC4AZgByAG8AbQBKAHMAbwBuACgAZABhAHQAYQApADsACgAgACAAbABvAGcAKABkAGkAdAB0AG8ALgBuAGEAbQBlACkAOwAKAAoAfQApADsACgAKAAoA
I got an error: "unable to parse Pokemon:\n- Pokemon/id must be string"
It would have been nice to get a more clear error like "Found Pokemon.id was a number, but expected it to be a string"
No response
0.84.4
20.12.2
MacOS
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I tried this:
https://www.winglang.io/play/?code=YgByAGkAbgBnACAAaAB0AHQAcAA7AAoAYgByAGkAbgBnACAAYwBsAG8AdQBkADsACgAKAHMAdAByAHUAYwB0ACAAUABvAGsAZQBtAG8AbgAgAHsACgAgACAAaQBkADoAIABzAHQAcgA7AAoAIAAgAG4AYQBtAGUAOgAgAHMAdAByADsACgAgACAAbwByAGQAZQByADoAIABuAHUAbQA7AAoAIAAgAHcAZQBpAGcAaAB0ADoAIABuAHUAbQA7AAoAfQAKAAoAbgBlAHcAIABjAGwAbwB1AGQALgBGAHUAbgBjAHQAaQBvAG4AKABpAG4AZgBsAGkAZwBoAHQAIAAoACkAIAA9AD4AIAB7AAoAIAAgAGwAZQB0ACAAeAAgAD0AIABoAHQAdABwAC4AZwBlAHQAKAAiAGgAdAB0AHAAcwA6AC8ALwBwAG8AawBlAGEAcABpAC4AYwBvAC8AYQBwAGkALwB2ADIALwBwAG8AawBlAG0AbwBuAC8AZABpAHQAdABvACIAKQA7AAoACgAgACAALwAvACAAcgBlAHMAcABvAG4AcwBlACAAcwB0AGEAdAB1AHMACgAgACAAbABvAGcAKAB4AC4AcwB0AGEAdAB1AHMAKQA7AAoACgAgACAAbABlAHQAIABkAGEAdABhACAAPQAgAEoAcwBvAG4ALgBwAGEAcgBzAGUAKAB4AC4AYgBvAGQAeQApADsACgAKACAAIAAvAC8AIABDAGEAcwB0ACAAcgBlAHMAcABvAG4AcwBlACAAYgBhAGMAawAgAGkAbgB0AG8AIABzAHQAcgB1AGMAdAAKACAAIABsAGUAdAAgAGQAaQB0AHQAbwAgAD0AIABQAG8AawBlAG0AbwBuAC4AZgByAG8AbQBKAHMAbwBuACgAZABhAHQAYQApADsACgAgACAAbABvAGcAKABkAGkAdAB0AG8ALgBuAGEAbQBlACkAOwAKAAoAfQApADsACgAKAAoA
This happened:
I got an error: "unable to parse Pokemon:\n- Pokemon/id must be string"
I expected this:
It would have been nice to get a more clear error like "Found Pokemon.id was a number, but expected it to be a string"
Is there a workaround?
No response
Anything else?
No response
Wing Version
0.84.4
Node.js Version
20.12.2
Platform(s)
MacOS
Community Notes
The text was updated successfully, but these errors were encountered: