aboutsummaryrefslogtreecommitdiff
path: root/qobject/qjson.c
diff options
context:
space:
mode:
Diffstat (limited to 'qobject/qjson.c')
-rw-r--r--qobject/qjson.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/qobject/qjson.c b/qobject/qjson.c
index 9a0de89079..339c9f7de2 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -12,6 +12,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "qapi/qmp/json-lexer.h"
#include "qapi/qmp/json-parser.h"
#include "qapi/qmp/json-streamer.h"
@@ -24,15 +25,17 @@ typedef struct JSONParsingState
JSONMessageParser parser;
va_list *ap;
QObject *result;
+ Error *err;
} JSONParsingState;
static void parse_json(JSONMessageParser *parser, GQueue *tokens)
{
JSONParsingState *s = container_of(parser, JSONParsingState, parser);
- s->result = json_parser_parse(tokens, s->ap);
+
+ s->result = json_parser_parse_err(tokens, s->ap, &s->err);
}
-QObject *qobject_from_jsonv(const char *string, va_list *ap)
+QObject *qobject_from_jsonv(const char *string, va_list *ap, Error **errp)
{
JSONParsingState state = {};
@@ -43,12 +46,13 @@ QObject *qobject_from_jsonv(const char *string, va_list *ap)
json_message_parser_flush(&state.parser);
json_message_parser_destroy(&state.parser);
+ error_propagate(errp, state.err);
return state.result;
}
QObject *qobject_from_json(const char *string)
{
- return qobject_from_jsonv(string, NULL);
+ return qobject_from_jsonv(string, NULL, NULL);
}
/*
@@ -61,7 +65,7 @@ QObject *qobject_from_jsonf(const char *string, ...)
va_list ap;
va_start(ap, string);
- obj = qobject_from_jsonv(string, &ap);
+ obj = qobject_from_jsonv(string, &ap, NULL);
va_end(ap);
assert(obj != NULL);