PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/onbloc/json/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
onbloc / json
Files
24 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/onbloc/json/v0
gno
0.9

Files (24)

  • README.mdmarkdown
  • gnomod.tomltoml
  • buffer.gnogno
  • builder.gnogno
  • decode.gnogno
  • encode.gnogno
  • errors.gnogno
  • escape.gnogno
  • indent.gnogno
  • internal.gnogno
  • node.gnogno
  • parser.gnogno
  • path.gnogno
  • token.gnogno
  • buffer_test.gnogno
  • builder_test.gnogno
  • decode_test.gnogno
  • encode_test.gnogno
  • escape_test.gnogno
  • indent_test.gnogno
  • node_test.gnogno
  • parser_test.gnogno
  • path_test.gnogno
  • LICENSEother
  • path.gnogno
    1package json23import (4	"errors"5)67// ParsePath takes a JSONPath string and returns a slice of strings representing the path segments.8func ParsePath(path string) ([]string, error) {9	buf := newBuffer([]byte(path))10	result := make([]string, 0)1112	for {13		b, err := buf.current()14		if err != nil {15			break16		}1718		switch {19		case b == dollarSign || b == atSign:20			result = append(result, string(b))21			buf.step()2223		case b == dot:24			buf.step()2526			if next, _ := buf.current(); next == dot {27				buf.step()28				result = append(result, "..")2930				extractNextSegment(buf, &result)31			} else {32				extractNextSegment(buf, &result)33			}3435		case b == bracketOpen:36			start := buf.index37			buf.step()3839			for {40				if buf.index >= buf.length || buf.data[buf.index] == bracketClose {41					break42				}4344				buf.step()45			}4647			if buf.index >= buf.length {48				return nil, errors.New("unexpected end of path")49			}5051			segment := string(buf.sliceFromIndices(start+1, buf.index))52			result = append(result, segment)5354			buf.step()5556		default:57			buf.step()58		}59	}6061	return result, nil62}6364// extractNextSegment extracts the segment from the current index65// to the next significant character and adds it to the resulting slice.66func extractNextSegment(buf *buffer, result *[]string) {67	start := buf.index68	buf.skipToNextSignificantToken()6970	if buf.index <= start {71		return72	}7374	segment := string(buf.sliceFromIndices(start, buf.index))75	if segment != "" {76		*result = append(*result, segment)77	}78}79

    Functions

    not supported for pure packages by the node (vm/qfuncs)

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.