Forums - JSON parsing issue

2 posts / 0 new
Last post
JSON parsing issue
kozma.monika
Join Date: 27 Aug 19
Posts: 1
Posted: Thu, 2020-03-05 01:53
There is a limited JSON parsing functionality implemented with the qapi_JSON_... functions.
 
For example lets have the following JSON data:
 
    {
        "known_key1" : "with value 1",
        "known_key2" : "with value 2"
    }
 
After decoding with the qapi_JSON_Decode() function we get the internal handle to read out the JSON values. With the qapi_JSON_Query_By_Key(handle, "known_kex1", &value) or qapi_JSON_Query_By_Index(handle, 0, &value) functions we can get the proper values.
 
But lets assume we would like to parse an arbitrary JSON structure with arbitrary keys. For example:
 
    {
        "arbitrary_key1" : "with value 1",
        "arbitrary_key2" : "with value 2"
    }
 
We might call the qapi_JSON_Query_By_Key(handle, ???, &value), but what do we set for the key value?
 
On the other hand if we use the qapi_JSON_Query_By_Index(handle, 0, &value) function we get the value, but we do not know then which key it belongs to.
 
Is there any support for reading out arbitrary JSON key/value pairs? Can we get somehow iterate through a list of arbitrary JSON entries and get both the keys and related values?
 
Based on the QCA402x QAPI Specification 80-Y9381-7 Rev. H released on May 6, 2019 this doesn't seem viable.
 
Best regards,
Monika Kiss

 

  • Up0
  • Down0
Re: JSON parsing issue Best Answer
c_rpedad
Profile picture
Join Date: 18 Jun 18
Location: San Jose
Posts: 317
Posted: Tue, 2020-03-31 20:30

Kindly refer to json_demo.c file and let us know if this helps.
Path : @target\quartz\demo\QCLI_demo\src\enc\json_demo.c

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.