Parse key value pairs

This commit is contained in:
Benoit Blanchon
2014-10-21 23:37:17 +02:00
parent cfbe50057a
commit 04330a7a47
7 changed files with 103 additions and 31 deletions

View File

@ -41,7 +41,7 @@ namespace ArduinoJson
{
const char* key;
JsonNode* value;
} asKey;
} asKeyValue;
struct
{
@ -106,8 +106,8 @@ namespace ArduinoJson
void setAsObjectKeyValue(const char* key, JsonNode* value)
{
type = JSON_KEY_VALUE;
content.asKey.key = key;
content.asKey.value = value;
content.asKeyValue.key = key;
content.asKeyValue.value = value;
}
bool getAsBoolean()
@ -144,12 +144,12 @@ namespace ArduinoJson
const char* getAsObjectKey()
{
return type == JSON_KEY_VALUE ? content.asKey.key : 0;
return type == JSON_KEY_VALUE ? content.asKeyValue.key : 0;
}
JsonNode* getAsObjectValue()
{
return type == JSON_KEY_VALUE ? content.asKey.value : 0;
return type == JSON_KEY_VALUE ? content.asKeyValue.value : 0;
}
JsonNode* getProxyTarget()

View File

@ -29,6 +29,7 @@ namespace ArduinoJson
inline bool isArrayStop();
inline bool isBoolean();
inline bool isComma();
inline bool isColon();
inline bool isDouble();
inline bool isEnd();
inline bool isLong();
@ -41,13 +42,13 @@ namespace ArduinoJson
inline void skipSpaces();
inline JsonNode* parseArray();
inline JsonNode* parseBoolean();
inline JsonNode* parseBoolean();
inline JsonNode *parseDouble();
inline JsonNode* parseObjectKeyValue();
inline JsonNode* parseLong();
inline JsonNode* parseNull();
inline JsonNode* parseObject();
inline JsonNode* parseString();
JsonNode *parseDouble();
};
}
}

View File

@ -46,6 +46,7 @@ namespace ArduinoJson
Internals::JsonNode* createDoubleNode(double value, int decimals);
Internals::JsonNode* createLongNode(long value);
Internals::JsonNode* createObjectNode();
Internals::JsonNode* createObjectKeyValueNode(const char* key, Internals::JsonNode* value);
Internals::JsonNode* createStringNode(const char* value);
};
}