Closed derphilipp closed 1 week ago
[aside: I'd prefer questions like this under Discussions]
Yes. You don't even need to write a Go program for the validation. That said, I think our editing experience is better than most JSON experiences. I guess "existing tools" might be a deal-breaker. Anyway, yes, you can always add the following to any template;
import "pkl:json"
import "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped@1.0.2#/deepToTyped.pkl"
output {
value = deepToTyped.apply(module.getClass(), new json.Parser {}.parse(read(read("prop:JsonPath"))))
}
Now, if you invoke Pkl with a value for external property JsonPath
to point to your .json
file, you can consume output.value
as an instance of the module it's defined in.
Thank you very much and you are absolutely right, this should be under 'Discussion'!
Is it possible to achive:
This way golang programs could harness the power of pkl without modifying the user expirience / config files of existing tools