MCPcopy
hub / github.com/tidwall/sjson / appendBuild

Function appendBuild

sjson.go:136–162  ·  view source on GitHub ↗

appendBuild builds a json block from a json path.

(buf []byte, array bool, paths []pathResult, raw string,
	stringify bool)

Source from the content-addressed store, hash-verified

134
135// appendBuild builds a json block from a json path.
136func appendBuild(buf []byte, array bool, paths []pathResult, raw string,
137 stringify bool) []byte {
138 if !array {
139 buf = appendStringify(buf, paths[0].part)
140 buf = append(buf, ':')
141 }
142 if len(paths) > 1 {
143 n, numeric := atoui(paths[1])
144 if numeric || (!paths[1].force && paths[1].part == "-1") {
145 buf = append(buf, '[')
146 buf = appendRepeat(buf, "null,", n)
147 buf = appendBuild(buf, true, paths[1:], raw, stringify)
148 buf = append(buf, ']')
149 } else {
150 buf = append(buf, '{')
151 buf = appendBuild(buf, false, paths[1:], raw, stringify)
152 buf = append(buf, '}')
153 }
154 } else {
155 if stringify {
156 buf = appendStringify(buf, raw)
157 } else {
158 buf = append(buf, raw...)
159 }
160 }
161 return buf
162}
163
164// atoui does a rip conversion of string -> unigned int.
165func atoui(r pathResult) (n int, ok bool) {

Callers 1

appendRawPathsFunction · 0.85

Calls 3

appendStringifyFunction · 0.85
atouiFunction · 0.85
appendRepeatFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…