Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I tried to attempt in many ways, e.g.
if(val["definitions"]["properties"]["Count"]["type"][0] == "number" and
(val["definitions"]["properties"]["Count"]["type"][1] == "null"))
//code here
This leads to the following error
error : terminate called after throwing an instance of 'Json::LogicError' what(): in Json::Value::operator: requires arrayValue Aborted (core dumped)
And for this piece of code
if (val["definitions"]["properties"]["Count"]["type"][0].isMember("number") and
(val["definitions"]["properties"]["Count"]["type"][0].isMember("null"))){
//code here
I get
error: terminate called after throwing an instance of 'Json::LogicError'
what(): in Json::Value::find(key, end, found): requires objectValue or nullValue Aborted (core dumped)
–
You code is right... your json is wrong... JsonCpp needs the quotes for "definitions" and you can't have extra commas after the last item in an array or object.
just change it to:
"definitions": {
"properties": {
"Count": {
"type": [
"number",
"null"
–
–
–
const Json::Value obj=val["definitions"]["properties"]["count"]["type"];
if (std::find(obj.begin(),obj.end(),"string")!=obj.end() and
std::find(obj.begin(),obj.end(),"null")!=obj.end()){
// code here;
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.