From 268e6b568ba8b3b17bb89ff4e685ddd4d87d4c34 Mon Sep 17 00:00:00 2001 From: lixiumei Date: Thu, 9 Dec 2021 17:57:14 +0800 Subject: [PATCH] Fix auto-code generation header file with #include json/json.h --- docs/json-api/neu_json_mqtt.json | 10 ---------- include/json/neu_json_error.h | 2 ++ include/json/neu_json_group_config.h | 2 ++ include/json/neu_json_node.h | 4 +++- include/json/neu_json_plugin.h | 2 ++ include/json/neu_json_rw.h | 4 ++-- include/json/neu_json_tag.h | 2 ++ include/json/neu_json_tty.h | 2 ++ src/parser/neu_json_node.c | 12 ++++++------ 9 files changed, 21 insertions(+), 19 deletions(-) delete mode 100644 docs/json-api/neu_json_mqtt.json diff --git a/docs/json-api/neu_json_mqtt.json b/docs/json-api/neu_json_mqtt.json deleted file mode 100644 index f6c85a0b..00000000 --- a/docs/json-api/neu_json_mqtt.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "mqtt_req": { - "function": 2, - "uuid": "554f5fd8-f437-11eb-975c-7704b9e17821" - }, - "mqtt_resp": { - "function": 2, - "uuid": "554f5fd8-f437-11eb-975c-7704b9e17821" - } -} \ No newline at end of file diff --git a/include/json/neu_json_error.h b/include/json/neu_json_error.h index ecb0c6e5..94f2984b 100644 --- a/include/json/neu_json_error.h +++ b/include/json/neu_json_error.h @@ -25,6 +25,8 @@ #ifndef _NEU_JSON_API_NEU_JSON_ERROR_H_ #define _NEU_JSON_API_NEU_JSON_ERROR_H_ +#include "json/json.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/include/json/neu_json_group_config.h b/include/json/neu_json_group_config.h index 2ff208ab..ad0626fd 100644 --- a/include/json/neu_json_group_config.h +++ b/include/json/neu_json_group_config.h @@ -25,6 +25,8 @@ #ifndef _NEU_JSON_API_NEU_JSON_GROUP_CONFIG_H_ #define _NEU_JSON_API_NEU_JSON_GROUP_CONFIG_H_ +#include "json/json.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/include/json/neu_json_node.h b/include/json/neu_json_node.h index aa34d757..09fd2cfc 100644 --- a/include/json/neu_json_node.h +++ b/include/json/neu_json_node.h @@ -25,6 +25,8 @@ #ifndef _NEU_JSON_API_NEU_JSON_NODE_H_ #define _NEU_JSON_API_NEU_JSON_NODE_H_ +#include "json/json.h" + #ifdef __cplusplus extern "C" { #endif @@ -73,8 +75,8 @@ typedef struct { int neu_json_encode_get_nodes_resp(void *json_object, void *param); typedef struct { - int64_t id; char * name; + int64_t id; } neu_json_update_node_req_t; int neu_json_decode_update_node_req(char * buf, diff --git a/include/json/neu_json_plugin.h b/include/json/neu_json_plugin.h index f2d080bf..0d408e16 100644 --- a/include/json/neu_json_plugin.h +++ b/include/json/neu_json_plugin.h @@ -25,6 +25,8 @@ #ifndef _NEU_JSON_API_NEU_JSON_PLUGIN_H_ #define _NEU_JSON_API_NEU_JSON_PLUGIN_H_ +#include "json/json.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/include/json/neu_json_rw.h b/include/json/neu_json_rw.h index 40d9e535..7144f664 100644 --- a/include/json/neu_json_rw.h +++ b/include/json/neu_json_rw.h @@ -25,12 +25,12 @@ #ifndef _NEU_JSON_API_NEU_JSON_RW_H_ #define _NEU_JSON_API_NEU_JSON_RW_H_ +#include "json/json.h" + #ifdef __cplusplus extern "C" { #endif -#include "json/json.h" - typedef struct { int64_t id; enum neu_json_type t; diff --git a/include/json/neu_json_tag.h b/include/json/neu_json_tag.h index 0ba6e5bd..f77f2ac5 100644 --- a/include/json/neu_json_tag.h +++ b/include/json/neu_json_tag.h @@ -25,6 +25,8 @@ #ifndef _NEU_JSON_API_NEU_JSON_TAG_H_ #define _NEU_JSON_API_NEU_JSON_TAG_H_ +#include "json/json.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/include/json/neu_json_tty.h b/include/json/neu_json_tty.h index 82a02365..79816e60 100644 --- a/include/json/neu_json_tty.h +++ b/include/json/neu_json_tty.h @@ -25,6 +25,8 @@ #ifndef _NEU_JSON_API_NEU_JSON_TTY_H_ #define _NEU_JSON_API_NEU_JSON_TTY_H_ +#include "json/json.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/src/parser/neu_json_node.c b/src/parser/neu_json_node.c index caee54a1..94987c7a 100644 --- a/src/parser/neu_json_node.c +++ b/src/parser/neu_json_node.c @@ -207,20 +207,20 @@ int neu_json_decode_update_node_req(char * buf, neu_json_update_node_req_t *req = calloc(1, sizeof(neu_json_update_node_req_t)); neu_json_elem_t req_elems[] = { { - .name = "id", - .t = NEU_JSON_INT, - }, - { .name = "name", .t = NEU_JSON_STR, + }, + { + .name = "id", + .t = NEU_JSON_INT, } }; ret = neu_json_decode(buf, NEU_JSON_ELEM_SIZE(req_elems), req_elems); if (ret != 0) { goto decode_fail; } - req->id = req_elems[0].v.val_int; - req->name = req_elems[1].v.val_str; + req->name = req_elems[0].v.val_str; + req->id = req_elems[1].v.val_int; *result = req; return ret;