Skip to content

Passing and returning complex data with a ResourceReader #384

Answered by bioball
rnapier asked this question in Q&A
Discussion options

You must be logged in to vote

Resource readers and query params is the right direction for this.

For URI encoding, there's an experimental URI package available that you can use; docs here: https://pkl-lang.org/package-docs/pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri/current/URI/index.html#encodeComponent%28%29

You can then combine this with JSON encoding if you wish:

import "pkl:json"
import "package://pkg.pkl-lang.org/pkl-pantry/[email protected]#/URI.pkl"

local jsonRenderer = new json.Renderer {}

allAccounts: Listing<String> = new {
    "Assets:Money Market"
    "Assets:Savings Bonds"
    "Assets:CDs"
    "Assets:Brokerage"
    "Assets:401k"
    "Assets:HSA"
}

local allAccountsRendererd = jsonRenderer

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rnapier
Comment options

Answer selected by rnapier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants