MCPcopy
hub / github.com/pquerna/ffjson / getArrayHandler

Function getArrayHandler

inception/decoder.go:193–246  ·  view source on GitHub ↗
(ic *Inception, name string, typ reflect.Type, ptr bool)

Source from the content-addressed store, hash-verified

191}
192
193func getArrayHandler(ic *Inception, name string, typ reflect.Type, ptr bool) string {
194 if typ.Kind() == reflect.Slice && typ.Elem().Kind() == reflect.Uint8 {
195 ic.OutputImports[`"encoding/base64"`] = true
196 useReflectToSet := false
197 if typ.Elem().Name() != "byte" {
198 ic.OutputImports[`"reflect"`] = true
199 useReflectToSet = true
200 }
201
202 return tplStr(decodeTpl["handleByteSlice"], handleArray{
203 IC: ic,
204 Name: name,
205 Typ: typ,
206 Ptr: reflect.Ptr,
207 UseReflectToSet: useReflectToSet,
208 })
209 }
210
211 if typ.Elem().Kind() == reflect.Struct && typ.Elem().Name() != "" {
212 goto sliceOrArray
213 }
214
215 if (typ.Elem().Kind() == reflect.Struct || typ.Elem().Kind() == reflect.Map) ||
216 typ.Elem().Kind() == reflect.Array || typ.Elem().Kind() == reflect.Slice &&
217 typ.Elem().Name() == "" {
218 ic.OutputImports[`"encoding/json"`] = true
219
220 return tplStr(decodeTpl["handleFallback"], handleFallback{
221 Name: name,
222 Typ: typ,
223 Kind: typ.Kind(),
224 })
225 }
226
227sliceOrArray:
228
229 if typ.Kind() == reflect.Array {
230 return tplStr(decodeTpl["handleArray"], handleArray{
231 IC: ic,
232 Name: name,
233 Typ: typ,
234 IsPtr: ptr,
235 Ptr: reflect.Ptr,
236 })
237 }
238
239 return tplStr(decodeTpl["handleSlice"], handleArray{
240 IC: ic,
241 Name: name,
242 Typ: typ,
243 IsPtr: ptr,
244 Ptr: reflect.Ptr,
245 })
246}
247
248func getAllowTokens(name string, tokens ...string) string {
249 return tplStr(decodeTpl["allowTokens"], allowTokens{

Callers 1

handleFieldAddrFunction · 0.85

Calls 1

tplStrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…