MCPcopy Create free account
hub / github.com/araddon/qlbridge / ParseJsonObject

Function ParseJsonObject

rel/parse_sql.go:2108–2134  ·  view source on GitHub ↗
(pg expr.TokenPager, jh u.JsonHelper)

Source from the content-addressed store, hash-verified

2106}
2107
2108func ParseJsonObject(pg expr.TokenPager, jh u.JsonHelper) error {
2109 if pg.Cur().T != lex.TokenLeftBrace {
2110 return pg.ErrMsg("Expected json {")
2111 }
2112 pg.Next() // Consume {
2113
2114 for {
2115 //u.Debug(pg.Cur())
2116 switch pg.Cur().T {
2117 case lex.TokenIdentity:
2118 if err := parseJsonKeyValue(pg, jh); err != nil {
2119 return err
2120 }
2121 default:
2122 return pg.ErrMsg("Expected json key identity")
2123 }
2124 switch pg.Cur().T {
2125 case lex.TokenComma:
2126 pg.Next()
2127 case lex.TokenRightBrace:
2128 pg.Next() // Consume the right }
2129 return nil
2130 default:
2131 return pg.ErrMsg("Expected json comma or end of object")
2132 }
2133 }
2134}
2135func parseJsonKeyValue(pg expr.TokenPager, jh u.JsonHelper) error {
2136 if pg.Cur().T != lex.TokenIdentity {
2137 return pg.ErrMsg("Expected json key/identity")

Callers 3

ParseWithFunction · 0.85
parseJsonKeyValueFunction · 0.85
ParseJsonArrayFunction · 0.85

Calls 4

parseJsonKeyValueFunction · 0.85
CurMethod · 0.65
ErrMsgMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected