| 3323 | } |
| 3324 | |
| 3325 | bool Value::isConvertibleTo(ValueType other) const { |
| 3326 | switch (other) { |
| 3327 | case nullValue: |
| 3328 | return (isNumeric() && asDouble() == 0.0) || |
| 3329 | (type_ == booleanValue && value_.bool_ == false) || |
| 3330 | (type_ == stringValue && asString() == "") || |
| 3331 | (type_ == arrayValue && value_.map_->size() == 0) || |
| 3332 | (type_ == objectValue && value_.map_->size() == 0) || |
| 3333 | type_ == nullValue; |
| 3334 | case intValue: |
| 3335 | return isInt() || |
| 3336 | (type_ == realValue && InRange(value_.real_, minInt, maxInt)) || |
| 3337 | type_ == booleanValue || type_ == nullValue; |
| 3338 | case uintValue: |
| 3339 | return isUInt() || |
| 3340 | (type_ == realValue && InRange(value_.real_, 0, maxUInt)) || |
| 3341 | type_ == booleanValue || type_ == nullValue; |
| 3342 | case realValue: |
| 3343 | return isNumeric() || type_ == booleanValue || type_ == nullValue; |
| 3344 | case booleanValue: |
| 3345 | return isNumeric() || type_ == booleanValue || type_ == nullValue; |
| 3346 | case stringValue: |
| 3347 | return isNumeric() || type_ == booleanValue || type_ == stringValue || |
| 3348 | type_ == nullValue; |
| 3349 | case arrayValue: |
| 3350 | return type_ == arrayValue || type_ == nullValue; |
| 3351 | case objectValue: |
| 3352 | return type_ == objectValue || type_ == nullValue; |
| 3353 | } |
| 3354 | JSON_ASSERT_UNREACHABLE; |
| 3355 | return false; |
| 3356 | } |
| 3357 | |
| 3358 | /// Number of values in array or object |
| 3359 | ArrayIndex Value::size() const { |