Utility Functions and C Language Reference > Utility Functions: C Language (lr_) > Alphabetical Listing > lr_json_get_values


Gets values from a path in a JSON object.

C Language

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

Example String and Parameter Functions


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.

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 is not applicable to this function.


This script shows the usage of lr_json_get_values.

	int i;
	// See File: store.json
	i = lr_eval_json("Buffer/File=store.json", 
	                 "JsonObject=s_json_obj", LAST);

	i = lr_json_get_values("JsonObject=s_json_obj",
	// 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",

	i = lr_json_get_values("JsonObject=s_json_obj",
	return 0;

TestGetValues.c(11): Notify: Saving Parameter "s_new_storename = Black Books".

TestGetValues.c(31): Notify: Parameter Substitution: parameter "s_path_isbn" = "$.store.books[*].isbn"

TestGetValues.c(31): Notify: Saving Parameter "s_new_isbn_1 = 1111".

TestGetValues.c(31): Notify: Saving Parameter "s_new_isbn_2 = 2222".

TestGetValues.c(31): Notify: Saving Parameter "s_new_isbn_Count = 2".

TestGetValues.c(31): lr_json_get_values succeed, 2 matches