| 626 | } |
| 627 | |
| 628 | String Value::asString() const { |
| 629 | switch (type()) { |
| 630 | case nullValue: |
| 631 | return ""; |
| 632 | case stringValue: { |
| 633 | if (value_.string_ == nullptr) |
| 634 | return ""; |
| 635 | unsigned this_len; |
| 636 | char const* this_str; |
| 637 | decodePrefixedString(this->isAllocated(), this->value_.string_, &this_len, |
| 638 | &this_str); |
| 639 | return String(this_str, this_len); |
| 640 | } |
| 641 | case booleanValue: |
| 642 | return value_.bool_ ? "true" : "false"; |
| 643 | case intValue: |
| 644 | return valueToString(value_.int_); |
| 645 | case uintValue: |
| 646 | return valueToString(value_.uint_); |
| 647 | case realValue: |
| 648 | return valueToString(value_.real_); |
| 649 | default: |
| 650 | JSON_FAIL_MESSAGE("Type is not convertible to string"); |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | Value::Int Value::asInt() const { |
| 655 | switch (type()) { |