| 501 | } |
| 502 | |
| 503 | static JSON parse_array( const std::string &str, size_t &offset ) { |
| 504 | JSON Array( JSON::Class::Array ); |
| 505 | size_t index = 0; |
| 506 | |
| 507 | ++offset; |
| 508 | consume_ws( str, offset ); |
| 509 | if( str.at(offset) == ']' ) { |
| 510 | ++offset; return Array; |
| 511 | } |
| 512 | |
| 513 | for (;offset < str.size();) { |
| 514 | Array[index++] = parse_next( str, offset ); |
| 515 | consume_ws( str, offset ); |
| 516 | |
| 517 | if( str.at(offset) == ',' ) { |
| 518 | ++offset; continue; |
| 519 | } |
| 520 | else if( str.at(offset) == ']' ) { |
| 521 | ++offset; break; |
| 522 | } |
| 523 | else { |
| 524 | throw std::runtime_error(std::string("JSON ERROR: Array: Expected ',' or ']', found '") + str.at(offset) + "'\n"); |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | return Array; |
| 529 | } |
| 530 | |
| 531 | static JSON parse_string( const std::string &str, size_t &offset ) { |
| 532 | std::string val; |