| 422 | |
| 423 | |
| 424 | JSON JSON::operator[] (size_t n) const |
| 425 | { |
| 426 | ElementType type = getType(); |
| 427 | |
| 428 | if (type != TYPE_ARRAY) |
| 429 | throw JSONException("JSON: not array when calling operator[](size_t) method."); |
| 430 | |
| 431 | Pos pos = ptr_begin; |
| 432 | ++pos; |
| 433 | checkPos(pos); |
| 434 | |
| 435 | size_t i = 0; |
| 436 | const_iterator it = begin(); |
| 437 | while (i < n && it != end()) |
| 438 | { |
| 439 | ++it; |
| 440 | ++i; |
| 441 | } |
| 442 | |
| 443 | if (i != n) |
| 444 | throw JSONException("JSON: array index " + std::to_string(n) + " out of bounds."); |
| 445 | |
| 446 | return *it; |
| 447 | } |
| 448 | |
| 449 | |
| 450 | JSON::Pos JSON::searchField(const char * data, size_t size) const |