![]() |
JSON Parser
1.0
|
| int json_find_member_value | ( | json_member_list_t * | result, |
| list_object * | json_data, | ||
| const char * | member_name, | ||
| const boolean | partial_name, | ||
| const char * | string_value, | ||
| const boolean | partial_value | ||
| ) |
Using the provided search criteria, search the JSON data and locate the first JSON object member in the list hierarchy that match the criteria, returning a pointer to it to the caller.
This function can be called to search only JSON Object Member names, or it can search for Member names and a string value criteria as well. For example, it can search the entire hierarchy for a JSON Object Members with the name "handle" or it could search for an Object Members with the name "roles" and the value "technical", which would return the first Object Member named "roles" that also has a string value of "technical". The value of course could be a data value in an JSON Array, depending on what the found Object Member had as a data value.
If you wish to get a list of all the JSON Object Members that matched the search criteria, you must use the function json_find_members_value_string() instead, which returns a list of Object Members instead.
This function may be called with an option to perform partial JSON Object Name and/or string value matches, so for the above example, a partial Object Name match for "role" would return the first Object Member which could be "role", roles" etc.
This function DOES NOT return the internal representation of the JSON Path with the match. This is because the json_member_list_t is supplied by the caller, and they could not have allocated it to cover unknown length of path.
Upon return if an Object Members was found that matched the search criteria, a pointer to the element and a pointer to the owning list_object will be returned in a json_member_list_t structure the caller already provided.
| [out] | result | A json_member_list_t struct which will be used to write the information about any JSON Object Member found that matched the search criteria. Only one Member will be returned, even if there are more that matched the criteria. |
| [in] | json_data | A D-List list_object that describes the JSON data to be searched. This can be a root list_object, or it can be any subordinate list_object within that hierarchy. It can be an Array or an Object list. The search is confined to the list(s) covered by this top level list_object. |
| [in] | member_name | Pointer to a nul terminated string to use as a match against the JSON Object Member names in the JSON data list. |
| [in] | partial_name | TRUE perform the search using member_name as a partial name match, FALSE perform the search looking only for a complete match with member_name. |
| [in] | string_value | Optional pointer to a nul terminated string to use as a match against the JSON Object Member values in the JSON data list, that have already matched with member_name, and have the value type of JSON_string. NULL to perform a search for only JSON OObject Member names, and not involving any search of Object Member values. |
| [in] | partial_value | TRUE perform the search using string_value as a partial string value match, only value if string_value is not NULL. FALSE perform the search looking only for a complete string value match with string_value. |
| 0 | No JSON Object Members were found that matched the search criteria. |
| >0 | The number of JSON Object Members found that matched the search criteria. Only the first match found was returned in the struct results, no JSON path is included. |
| <0 | An error occurred |