JSONLib: tune convert to string code
@@ -308,16 +308,10 @@ String CJSONEntry::getStringObject( const char* name, const char* szDefValue )
struct json_object* obj = json_object_object_get(m_object,const_cast<char*>(name));
if ( obj != 0 )
{
- if (json_object_is_type(obj,json_type_string)) {
- int len = json_object_get_string_len(obj);
- const char* str = json_object_get_string(obj);
+ size_t len = 0;
+ const char* str = json_object_to_json_string_length(obj, JSON_C_TO_STRING_SPACED, &len);
return String(str, len);
}
- else {
- const char* str = json_object_get_string(obj);
- return String(str);
- }
- }
else if (szDefValue != 0 )
{
return String(szDefValue);
@@ -329,16 +323,10 @@ String CJSONEntry::getStringObject( const char* name, const char* szDefValue )
String CJSONEntry::getStringObject()
{
- if (isString()) {
- int len = json_object_get_string_len(m_object);
- const char* str = json_object_get_string(m_object);
+ size_t len = 0;
+ const char* str = json_object_to_json_string_length(m_object, JSON_C_TO_STRING_SPACED, &len);
return String(str, len);
}
- else {
- const char* str = json_object_get_string(m_object);
- return String(str);
- }
-}
const char* CJSONEntry::getString(const char* name)
