-
Notifications
You must be signed in to change notification settings - Fork 217
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
How to read/write json data using starlark? #215
Comments
We don't yet have a module for JSON access, though there is clearly a need. I posted a first draft in #179 but have not had time to finish it off. I hope to return to it in the near future, in combination with support for reading and writing protocol messages. I think the combination will open many doors for new tooling. |
I would like to see the |
I'd like to build a complex object (like a Kubernetes resource) in a starlark script and return it back to my Go program as a JSON script or something that can be easily parsed in the same manager as JSON. |
@errordeveloper , for Kubernetes YAML, the better option will the kyaml library which preserves the comments, yaml order etc. There are some examples here: |
@tamalsaha interesting, didn't expect that kustomize would add starlark in, I was previously told it would be against the original design... Will have a good look, thanks! For now I am actually quite keen to try out CUE for the use-case at hand. |
@tamalsaha maybe https://github.com/cruise-automation/isopod would be of interest. It uses implementation in skycfg (https://github.com/stripe/skycfg/blob/2a2d2baed02b9ef17e98fdbdd1d7255e9adfbad3/internal/go/skycfg/json_write.go#L45) to render json for CRD types (but normally uses Protobuf wire format where supported) |
PR #179 is committed, so you can start to use json.encode and json.decode within your Starlark application. Of course Starlark programs still cannot read or write files unless the application provides a way to do that. I may move the Go code into a lib/json directory, which is a breaking API change but not a breaking Starlark language change. Please try it out and report any problems. |
Is there any example that shows how to read write json data using starlark ?
The text was updated successfully, but these errors were encountered: