Skip to content

add UnmarshalPartially#15

Open
davidwtf wants to merge 1 commit intohjson:masterfrom
davidwtf:master
Open

add UnmarshalPartially#15
davidwtf wants to merge 1 commit intohjson:masterfrom
davidwtf:master

Conversation

@davidwtf
Copy link
Copy Markdown

In our project, we use hjson as part of configs, it's mixed with other format texts.
So we need read the part of hjson by hjson-go and keep the left part to other programs.
I added the function UnmarshalPartially to do this work.
UnmarshalPartially reads characters from the beginning, add try to parse them as hjson.
It stops when meeting wrong formats or finishing a complete hjson structure.
It returns the parsed value, the start position of the unprocessed part and error if has.

@dqsully
Copy link
Copy Markdown
Member

dqsully commented Oct 7, 2019

This is a cool feature, but I'm not sure it fits in the official Hjson package. Maybe you could make a config format similar to how OctoberCMS does it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants