Test that JsonArray can contain doubles

This commit is contained in:
Benoit Blanchon
2014-10-05 15:02:40 +02:00
parent 21259bc61a
commit 99a785179d
4 changed files with 34 additions and 14 deletions

View File

@ -11,4 +11,31 @@ JsonValue JsonArray::operator[](int index) const
}
return JsonValue();
}
void JsonArray::add(char const* value)
{
JsonNode* node = createNode(JSON_STRING);
if (!node) return;
node->content.asString = value;
addChild(node);
}
void JsonArray::add(double value, int decimals)
{
JsonNode* node = createNode((JsonNodeType)(JSON_DOUBLE_0_DECIMALS + decimals));
if (!node) return;
node->content.asDouble = value;
addChild(node);
}
void JsonArray::add(long value)
{
JsonNode* node = createNode(JSON_INTEGER);
if (!node) return;
node->content.asInteger = value;
addChild(node);
}