(pg expr.TokenPager, jh u.JsonHelper)
| 2106 | } |
| 2107 | |
| 2108 | func 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 | } |
| 2135 | func parseJsonKeyValue(pg expr.TokenPager, jh u.JsonHelper) error { |
| 2136 | if pg.Cur().T != lex.TokenIdentity { |
| 2137 | return pg.ErrMsg("Expected json key/identity") |
no test coverage detected