| 171 | } |
| 172 | |
| 173 | Status JsonReader::ExtractString(const Value* object, |
| 174 | const char* field, |
| 175 | string* result) const { |
| 176 | const Value* val; |
| 177 | RETURN_NOT_OK(ExtractField(object, field, &val)); |
| 178 | if (PREDICT_FALSE(!val->IsString())) { |
| 179 | if (val->IsNull()) { |
| 180 | *result = ""; |
| 181 | return Status::OK(); |
| 182 | } |
| 183 | return Status::InvalidArgument(Substitute( |
| 184 | "wrong type during field extraction: expected string but got $0", |
| 185 | TypeToString(val->GetType()))); |
| 186 | } |
| 187 | result->assign(val->GetString()); |
| 188 | return Status::OK(); |
| 189 | } |
| 190 | |
| 191 | Status JsonReader::ExtractObject(const Value* object, |
| 192 | const char* field, |