appendBuild builds a json block from a json path.
(buf []byte, array bool, paths []pathResult, raw string, stringify bool)
| 134 | |
| 135 | // appendBuild builds a json block from a json path. |
| 136 | func 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. |
| 165 | func atoui(r pathResult) (n int, ok bool) { |
no test coverage detected
searching dependent graphs…