Skip to content
New issue

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

[FAQ] What type of return value is json.decode() or yaml.decode() in KCL #163

Closed
Peefy opened this issue Sep 19, 2023 · 4 comments
Closed
Labels
faq help wanted Extra attention is needed

Comments

@Peefy
Copy link
Contributor

Peefy commented Sep 19, 2023

No description provided.

@Peefy Peefy added faq help wanted Extra attention is needed labels Sep 19, 2023
@octonawish-akcodes
Copy link
Contributor

Can i get some context here?

@Peefy
Copy link
Contributor Author

Peefy commented Feb 1, 2024

Can i get some context here?

A: The json.decode and yaml.decode functions both return the any type, which you can assign to any type. It will automatically convert and check the type at KCL runtime, as shown in the following code.

import yaml

schema Server:
    ports: [int]

server: Server = yaml.decode("""\
ports:
- 80
- 8080
""")

@d4v1d03
Copy link
Contributor

d4v1d03 commented Feb 20, 2024

Added a PR @Peefy , please have a look

@Peefy
Copy link
Contributor Author

Peefy commented Feb 20, 2024

Closed by #282

@Peefy Peefy closed this as completed Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
faq help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants