MCPcopy Index your code
hub / github.com/tidwall/gjson / parseArrayPath

Function parseArrayPath

gjson.go:774–832  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

772}
773
774func parseArrayPath(path string) (r arrayPathResult) {
775 for i := 0; i < len(path); i++ {
776 if path[i] == '|' {
777 r.part = path[:i]
778 r.pipe = path[i+1:]
779 r.piped = true
780 return
781 }
782 if path[i] == '.' {
783 r.part = path[:i]
784 if !r.arrch && i < len(path)-1 && isDotPiperChar(path[i+1:]) {
785 r.pipe = path[i+1:]
786 r.piped = true
787 } else {
788 r.path = path[i+1:]
789 r.more = true
790 }
791 return
792 }
793 if path[i] == '#' {
794 r.arrch = true
795 if i == 0 && len(path) > 1 {
796 if path[1] == '.' {
797 r.alogok = true
798 r.alogkey = path[2:]
799 r.path = path[:1]
800 } else if path[1] == '[' || path[1] == '(' {
801 // query
802 r.query.on = true
803 qpath, op, value, _, fi, vesc, ok :=
804 parseQuery(path[i:])
805 if !ok {
806 // bad query, end now
807 break
808 }
809 if len(value) >= 2 && value[0] == '"' &&
810 value[len(value)-1] == '"' {
811 value = value[1 : len(value)-1]
812 if vesc {
813 value = unescape(value)
814 }
815 }
816 r.query.path = qpath
817 r.query.op = op
818 r.query.value = value
819
820 i = fi - 1
821 if i+1 < len(path) && path[i+1] == '#' {
822 r.query.all = true
823 }
824 }
825 }
826 continue
827 }
828 }
829 r.part = path
830 r.path = ""
831 return

Callers 1

parseArrayFunction · 0.85

Calls 3

isDotPiperCharFunction · 0.85
parseQueryFunction · 0.85
unescapeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…