From b6e3a37ad93cd4ee883f41de7387742c743fbb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Blanchon?= Date: Thu, 17 Jul 2014 12:37:35 +0200 Subject: [PATCH] Added JsonParserBase::parse() that returns a JsonValue --- JsonParser/JsonParserBase.cpp | 6 +++--- JsonParser/JsonParserBase.h | 12 ++++++------ JsonParser/JsonValue.h | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/JsonParser/JsonParserBase.cpp b/JsonParser/JsonParserBase.cpp index ada66dde..0d2d274c 100644 --- a/JsonParser/JsonParserBase.cpp +++ b/JsonParser/JsonParserBase.cpp @@ -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); } diff --git a/JsonParser/JsonParserBase.h b/JsonParser/JsonParserBase.h index e08bf2dd..569cde01 100644 --- a/JsonParser/JsonParserBase.h +++ b/JsonParser/JsonParserBase.h @@ -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); }; } } \ No newline at end of file diff --git a/JsonParser/JsonValue.h b/JsonParser/JsonValue.h index 3f5ac546..0dd5d700 100644 --- a/JsonParser/JsonValue.h +++ b/JsonParser/JsonValue.h @@ -6,7 +6,6 @@ #pragma once #include "jsmn.h" - #include "JsonObjectBase.h" namespace ArduinoJson