Skip to content

Commit 137689a

Browse files
committed
chore: annotate exported symbols
1 parent b154238 commit 137689a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

jsonc.go

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"unicode"
88
)
99

10+
// Jsonc is the structure for parsing json with comments
1011
type Jsonc struct {
1112
comment int
1213
commaPos int
@@ -15,17 +16,20 @@ type Jsonc struct {
1516
len int
1617
}
1718

19+
// New creates Jsonc struct with proper defaults
1820
func New() *Jsonc {
1921
return &Jsonc{0, -1, false, 0, 0}
2022
}
2123

24+
// Strip strips comments and trailing commas from input byte array
2225
func (j *Jsonc) Strip(jsonb []byte) []byte {
2326
s := j.StripS(string(jsonb))
2427
return []byte(s)
2528
}
2629

2730
var crlf = map[string]string{"\n": `\n`, "\t": `\t`, "\r": `\r`}
2831

32+
// StripS strips comments and trailing commas from input string
2933
func (j *Jsonc) StripS(data string) string {
3034
var oldprev, prev, char, next, s string
3135

@@ -59,10 +63,12 @@ func (j *Jsonc) StripS(data string) string {
5963
return s
6064
}
6165

66+
// Unmarshal strips and parses the json byte array
6267
func (j *Jsonc) Unmarshal(jsonb []byte, v interface{}) error {
6368
return json.Unmarshal(j.Strip(jsonb), v)
6469
}
6570

71+
// UnmarshalFile strips and parses the json content from file
6672
func (j *Jsonc) UnmarshalFile(file string, v interface{}) error {
6773
jsonb, err := ioutil.ReadFile(file)
6874
if err != nil {

0 commit comments

Comments
 (0)