()
| 107 | } |
| 108 | |
| 109 | func (p *pgparser) ReadJSON() ([]byte, error) { |
| 110 | p.Unread() |
| 111 | |
| 112 | c, err := p.ReadByte() |
| 113 | if err != nil { |
| 114 | return nil, err |
| 115 | } |
| 116 | |
| 117 | p.buf = p.buf[:0] |
| 118 | |
| 119 | depth := 0 |
| 120 | for { |
| 121 | switch c { |
| 122 | case '{': |
| 123 | depth++ |
| 124 | case '}': |
| 125 | depth-- |
| 126 | } |
| 127 | |
| 128 | p.buf = append(p.buf, c) |
| 129 | |
| 130 | if depth == 0 { |
| 131 | break |
| 132 | } |
| 133 | |
| 134 | next, err := p.ReadByte() |
| 135 | if err != nil { |
| 136 | return nil, err |
| 137 | } |
| 138 | |
| 139 | c = next |
| 140 | } |
| 141 | |
| 142 | return p.buf, nil |
| 143 | } |