API Reference | developer.brewmp.com API Reference | developer.brewmp.com

Developer

API Reference

JSONPARSER_LOOKUP()

Brew Release
Brew MP 1.0.2
Description
The function provides a generic mechanism to access any JSON value using the string format described below.
Format uses period (".") as the separator and hence strings with periods cannot use this function for lookup. Format is divided into multiple segments with each segment except last forming an hierarchy of containers. The last segment identifies the leaf node and for objects this would be a key and for arrays an index number.
Examples: JSON: { "Address" : {"Street Name": {"Name": "Main Blvd", "Number": 1111 }}} Path: "Address.Street Name.Number" Retrieves: 1111
JSON: [0, 1, { "x" : 234.45} ] Path: "2.x" Retrieves: 234.45
JSON: { "auth": { "options" : ["rc4", "aes"] } } Path: "auth.options.0" Retrieves: "rc4"
Params
pj
[]:
JSON context
id
[]:
JSONObject or JSONArray ID
szPath
[]:
string parsed to identify the value location
pidValue
[]:
Value ID
Interface
Prototype
  •    int JSONParser_Lookup(JSONParser *pj, JSONID id, const char *szPath, int nLen,
                         JSONID *pValID);
                               
Return
  • JSONPARSER_SUCCESS on success, otherwise JSONPARSER_ERROR On success, pidValue is updated with relevant ID