MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / parse_array

Method parse_array

include/chaiscript/utility/json.hpp:503–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 2

stringClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected