1
0
Fork 0

Type-correct decoding of JSON to props.

This commit is contained in:
James Turner 2014-06-12 19:58:13 +01:00
parent d1a477324e
commit 8f754a1673

View file

@ -114,18 +114,30 @@ void JSON::toProp(cJSON * json, SGPropertyNode_ptr base)
toProp(cJSON_GetArrayItem(children, i), n);
}
} else {
//TODO: set correct type
/*
char * type = "";
cj = cJSON_GetObjectItem( json, "type" );
if( NULL != cj ) type = cj->valuestring;
*/
char * value = NULL;
cj = cJSON_GetObjectItem(json, "value");
if (NULL != cj) value = cj->valuestring;
if (NULL != cj) {
switch ( cj->type ) {
case cJSON_String:
n->setStringValue(cj->valuestring);
break;
if (NULL != value) n->setUnspecifiedValue(value);
}
case cJSON_Number:
n->setDoubleValue(cj->valuedouble);
break;
case cJSON_True:
n->setBoolValue(true);
break;
case cJSON_False:
n->setBoolValue(false);
break;
default:
break;
}
} // of have value
} // of no children
}
void JSON::addChildrenToProp(cJSON * json, SGPropertyNode_ptr n)