how to marshal my type information in pkl into json? #296
-
how to marshal my type information in pkl into json? Workaround right now: just define a class as struct then write my type information as data to marshal to json. my pkl file looks like:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
You can use the cli to render you pkl files to JSON and read it from any language you like: |
Beta Was this translation helpful? Give feedback.
-
Some more information is needed here in order to help you out. What does your Pkl code look like, and what is your ideal Go and Typescript code? In Go, typealiases of string literal unions will turn into "enums". Sample Pkl code: https://github.com/apple/pkl-go-examples/blob/main/pkl/AppConfig.pkl#L42 Generated Go code: https://github.com/apple/pkl-go-examples/blob/main/gen/appconfig/loglevel/LogLevel.pkl.go |
Beta Was this translation helpful? Give feedback.
-
I try the reflect harder . Here is the pkl code I got, it solve my origin problem: example.pkl
gen.pkl
pkl eval gen.pkl -f json
|
Beta Was this translation helpful? Give feedback.
I try the reflect harder . Here is the pkl code I got, it solve my origin problem:
example.pkl
gen.pkl