mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 04:52:22 +02:00
Added JsonParserBase::parse() that returns a JsonValue
This commit is contained in:
@ -7,13 +7,13 @@
|
|||||||
|
|
||||||
using namespace ArduinoJson::Parser;
|
using namespace ArduinoJson::Parser;
|
||||||
|
|
||||||
jsmntok_t* JsonParserBase::parse(char* json)
|
JsonValue JsonParserBase::parse(char* json)
|
||||||
{
|
{
|
||||||
jsmn_parser parser;
|
jsmn_parser parser;
|
||||||
jsmn_init(&parser);
|
jsmn_init(&parser);
|
||||||
|
|
||||||
if (JSMN_SUCCESS != jsmn_parse(&parser, json, tokens, maxTokens))
|
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.
|
* Parse the JSON string and return a array.
|
||||||
*
|
*
|
||||||
* The content of the string may be altered to add '\0' at the
|
* The content of the string may be altered to add '\0' at the
|
||||||
* end of string tokens
|
* 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
|
* The content of the string may be altered to add '\0' at the
|
||||||
* end of string tokens
|
* end of string tokens
|
||||||
*/
|
*/
|
||||||
JsonHashTable parseHashTable(char* json)
|
DEPRECATED JsonHashTable parseHashTable(char* json)
|
||||||
{
|
{
|
||||||
return JsonHashTable(json, parse(json));
|
return (JsonHashTable)parse(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
jsmntok_t* tokens;
|
jsmntok_t* tokens;
|
||||||
int maxTokens;
|
int maxTokens;
|
||||||
|
|
||||||
jsmntok_t* parse(char* json);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "jsmn.h"
|
#include "jsmn.h"
|
||||||
|
|
||||||
#include "JsonObjectBase.h"
|
#include "JsonObjectBase.h"
|
||||||
|
|
||||||
namespace ArduinoJson
|
namespace ArduinoJson
|
||||||
|
Reference in New Issue
Block a user