Skip to content

Question about Usage #479

Answered by AsterDY
kuro337 asked this question in Q&A
Discussion options

You must be logged in to vote

For question 1: It's mainly about cocurrency safty --- you can pass any []byte to sonic as long as you can ensure it is not being used by other goroutines at the same time.
For question 2: At present sonic doesn't implement json formalization by itself. You can use encoding/json's API to print
For question 3: not totally understand your question. I guess you mean you didn't know the whole schema for json but has some known fields --- for this situation you have two choice:

  • sonic supports partial schema and skip unknown fields, therefore you can define a partial struct only having known fields to be used as argument of Unmarshal()
  • use sonic.Get(). Translate these known fields into pathes …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AsterDY
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