Skip to content

how to marshal my type information in pkl into json? #296

Closed Answered by bronze1man
bronze1man asked this question in Q&A
Discussion options

You must be logged in to vote

I try the reflect harder . Here is the pkl code I got, it solve my origin problem:

example.pkl

typealias UiPage_t = UiListPage_t | UiEditPage_t
class UiEditPage_t{
  Title:String
  SubmitUrl:String
  TextFieldList:Listing<String>
}
class UiListPage_t{
  Title:String
  FieldList:Listing<String>
}

gen.pkl

import "example.pkl" as inModule
import "pkl:reflect"

class Gen_define_t{
  Name:String
  Type:"Class"|"Union"
  ClassFieldList:List<Gen_Field_t>?
  UnionTypeList:List<Gen_Type_t>?
  Debug1:String?
}
class Gen_Field_t{
  Name:String
  Type:Gen_Type_t
}
class Gen_Type_t{
  Type1:String
  ListElemType:Gen_Type_t?
}
function convType(type:reflect.Type):Gen_Type_t =
  let(_type1 = if (type i…

Replies: 3 comments 2 replies

Comment options

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

Comment options

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

Comment options

You must be logged in to vote
0 replies
Answer selected by bronze1man
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants