Signed-off-by: Soshi Katsuta <katsuta_soshi@cyberagent.co.jp>
| ... | ... |
@@ -232,6 +232,11 @@ func parseString(rest string) (*Node, map[string]bool, error) {
|
| 232 | 232 |
|
| 233 | 233 |
// parseJSON converts JSON arrays to an AST. |
| 234 | 234 |
func parseJSON(rest string) (*Node, map[string]bool, error) {
|
| 235 |
+ rest = strings.TrimLeftFunc(rest, unicode.IsSpace) |
|
| 236 |
+ if !strings.HasPrefix(rest, "[") {
|
|
| 237 |
+ return nil, nil, fmt.Errorf("Error parsing \"%s\" as a JSON array", rest)
|
|
| 238 |
+ } |
|
| 239 |
+ |
|
| 235 | 240 |
var myJSON []interface{}
|
| 236 | 241 |
if err := json.NewDecoder(strings.NewReader(rest)).Decode(&myJSON); err != nil {
|
| 237 | 242 |
return nil, nil, err |