MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / allPathsWithDepth

Method allPathsWithDepth

pkg/util/json/json.go:1853–1874  ·  view source on GitHub ↗
(depth int)

Source from the content-addressed store, hash-verified

1851}
1852
1853func (j jsonObject) allPathsWithDepth(depth int) ([]JSON, error) {
1854 if len(j) == 0 || depth == 0 {
1855 return []JSON{j}, nil
1856 }
1857 ret := make([]JSON, 0, len(j))
1858 for i := range j {
1859 var paths []JSON
1860 var err error
1861 if depth > 0 {
1862 paths, err = j[i].v.allPathsWithDepth(depth - 1)
1863 } else {
1864 paths, err = j[i].v.allPathsWithDepth(depth)
1865 }
1866 if err != nil {
1867 return nil, err
1868 }
1869 for _, path := range paths {
1870 ret = append(ret, jsonObject{jsonKeyValuePair{k: j[i].k, v: path}})
1871 }
1872 }
1873 return ret, nil
1874}
1875
1876// FromDecimal returns a JSON value given a apd.Decimal.
1877func FromDecimal(v apd.Decimal) JSON {

Callers

nothing calls this directly

Calls 1

allPathsWithDepthMethod · 0.65

Tested by

no test coverage detected