Code Monkey home page Code Monkey logo

Comments (1)

edwardyangx avatar edwardyangx commented on May 30, 2024

Thanks very much for reporting this issue. I changed it to below in our internal repository and plan to publish this in next release. Please let me know if this is OK or not in your transplant

diff --git a/src/packages/LITE-utils/json_parser.c b/src/packages/LITE-utils/json_parser.c
index cb09af7..d58bdcb 100644
--- a/src/packages/LITE-utils/json_parser.c
+++ b/src/packages/LITE-utils/json_parser.c
@@ -183,6 +183,8 @@ int json_parse_name_value(char *p_cJsonStr, int iStrLen, json_parse_cb pfnCB, vo
 int json_get_value_by_name_cb(char *p_cName, int iNameLen, char *p_cValue, int iValueLen, int iValueType,
                               void *p_CBData)
 {
+    JSON_NV     *p_stNameValue = (JSON_NV *)p_CBData;
+
 #if (JSON_DEBUG == 1)
     int         i;
 
@@ -201,8 +203,6 @@ int json_get_value_by_name_cb(char *p_cName, int iNameLen, char *p_cValue, int i
     }
 #endif
 
-    JSON_NV     *p_stNameValue = (JSON_NV *)p_CBData;
-
     if (!strncmp(p_cName, p_stNameValue->pN, p_stNameValue->nLen)) {
         p_stNameValue->pV = p_cValue;
         p_stNameValue->vLen = iValueLen;
@@ -215,8 +215,9 @@ int json_get_value_by_name_cb(char *p_cName, int iNameLen, char *p_cValue, int i
 
 char *json_get_value_by_name(char *p_cJsonStr, int iStrLen, char *p_cName, int *p_iValueLen, int *p_iValueType)
 {
-    JSON_NV     stNV = { 0, 0, 0, 0 };
+    JSON_NV     stNV;
 
+    memset(&stNV, 0, sizeof(stNV));
     stNV.pN = p_cName;
     stNV.nLen = strlen(p_cName);
     if (JSON_RESULT_OK == json_parse_name_value(p_cJsonStr, iStrLen, json_get_value_by_name_cb, (void *)&stNV)) {

Your feedback is highly appreciated and welcome :)

from iotkit-embedded.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.