forked from bblanchon/ArduinoJson
Added JsonParserBase::parse() that returns a JsonValue
This commit is contained in:
@ -7,13 +7,13 @@
|
||||
|
||||
using namespace ArduinoJson::Parser;
|
||||
|
||||
jsmntok_t* JsonParserBase::parse(char* json)
|
||||
JsonValue JsonParserBase::parse(char* json)
|
||||
{
|
||||
jsmn_parser parser;
|
||||
jsmn_init(&parser);
|
||||
|
||||
if (JSMN_SUCCESS != jsmn_parse(&parser, json, tokens, maxTokens))
|
||||
return 0;
|
||||
return JsonValue();
|
||||
|
||||
return tokens;
|
||||
return JsonValue(json, tokens);
|
||||
}
|
||||
|
@ -21,15 +21,17 @@ namespace ArduinoJson
|
||||
{
|
||||
}
|
||||
|
||||
JsonValue parse(char* json);
|
||||
|
||||
/*
|
||||
* Parse the JSON string and return a array.
|
||||
*
|
||||
* The content of the string may be altered to add '\0' at the
|
||||
* end of string tokens
|
||||
*/
|
||||
JsonArray parseArray(char* json)
|
||||
DEPRECATED JsonArray parseArray(char* json)
|
||||
{
|
||||
return JsonArray(json, parse(json));
|
||||
return (JsonArray)parse(json);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -38,16 +40,14 @@ namespace ArduinoJson
|
||||
* The content of the string may be altered to add '\0' at the
|
||||
* end of string tokens
|
||||
*/
|
||||
JsonHashTable parseHashTable(char* json)
|
||||
DEPRECATED JsonHashTable parseHashTable(char* json)
|
||||
{
|
||||
return JsonHashTable(json, parse(json));
|
||||
return (JsonHashTable)parse(json);
|
||||
}
|
||||
|
||||
private:
|
||||
jsmntok_t* tokens;
|
||||
int maxTokens;
|
||||
|
||||
jsmntok_t* parse(char* json);
|
||||
};
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "jsmn.h"
|
||||
|
||||
#include "JsonObjectBase.h"
|
||||
|
||||
namespace ArduinoJson
|
||||
|
Reference in New Issue
Block a user