JSONLib: fix issue with convert string with zero symbols
@@ -308,9 +308,16 @@ 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);
+ return String(str, len);
+ }
+ else {
const char* str = json_object_get_string(obj);
return String(str);
}
+ }
else if (szDefValue != 0 )
{
return String(szDefValue);
@@ -322,9 +329,16 @@ 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);
+ return String(str, len);
+ }
+ else {
const char* str = json_object_get_string(m_object);
return String(str);
}
+}
const char* CJSONEntry::getString(const char* name)
