gbowne1 / gbowne1/jsonify

[Bug] getters have bad formatting

Open
#19 0 comments 0 reactions 0 assignees View on GitHub
bug documentation enhancement good first issue help wanted question
Dominant language
C++
Stars
4
Forks
6
PR merge metrics
No merged PRs in 30d

Description

jsonparser.cpp has logic errors and issues with getters

The getters should be something like

```c
double JsonValue::getNumber() const {
if (std::holds_alternative(value_)) { // Was checking for bool
return std::get(value_);
}
throw std::runtime_error("Cannot retrieve number value, types mismatch");
}

const JsonArray& JsonValue::getArray() const {
if (std::holds_alternative(value_)) { // Was checking for bool
return std::get(value_);
}
throw std::runtime_error("Cannot retrieve array value, types mismatch");
}

const JsonObject& JsonValue::getObject() const {
if (std::holds_alternative(value_)) { // Was checking for bool
return std::get(value_);
}
throw std::runtime_error("Cannot retrieve object value, types mismatch");
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.