Share this page

# lr_json_get_values

Gets values from a path in a JSON object.

int lr_json_get_values( "JsonObject=<parameter name>", "ValueParam=<parameter name>", "QueryString=<JSON query>", ["SelectAll=<Yes|No>",] ["NotFound=<Error|Continue>",] LAST );

Alphabetical Listing - C Language Utility Functions

## Arguments

Name | Comments
--- | ---
JsonObject | The name of the parameter that stores the handle of the JSON object created by lr_eval_json.
QueryString | The JSON query.
ValueParam | The name of a parameter to store the data found.
SelectAll | Optional: If Yes, finds all matches. If No, stops after first match. Default is No.
NotFound | Optional. One of: Error - Script run is aborted and error message is sent. (Default) Continue - Script run continues. A warning message is sent.
LAST | Required marker for the end of the argument list.

lr_json_get_values finds the data in the nodes that match the query and stores the data in the ValueParam parameter.

This function is not recorded. You can insert it manually into your script.

## Return Values

The number of matches.

## Parameterization

Parameterization is not applicable to this function.

## Example

This script shows the usage of lr_json_get_values.

Copy code

    TestGetValues()
    {
        int i;

        // See <MadCap:xref href="etc/lrFr_store_json.htm" xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd">File: store.json</MadCap:xref>
        i = lr_eval_json("Buffer/File=store.json",
                         "JsonObject=s_json_obj", LAST);

        i = lr_json_get_values("JsonObject=s_json_obj",
                    "ValueParam=s_new_storename",
                    "QueryString=$.store.name",
                     LAST);

        // Multi match with SelectAll=Yes
        lr_save_string("\"1111\"", "s_isbn_1");
        lr_save_string("\"2222\"", "s_isbn_2");
        lr_save_string("2", "s_isbn_count");

        lr_save_string("$.store.books[*].isbn", "s_path_isbn");

        i = lr_json_set_values("JsonObject=s_json_obj",
                        "ValueParam=s_isbn",
                        "QueryString={s_path_isbn}",
                        "SelectAll=Yes",
                         LAST);

        i = lr_json_get_values("JsonObject=s_json_obj",
                    "ValueParam=s_new_isbn",
                    "QueryString={s_path_isbn}",
                    "SelectAll=Yes",
                     LAST);

        return 0;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: