Share this page

# lr_eval_json

Creates a JSON object from a string or a file.

## C Language

int lr_eval_json( "Buffer or Buffer/File = <buffer>", "JsonObject = <parameter name>" );

Example | Parameter Functions

## Arguments

Name | Comments
--- | ---
Buffer | A JSON string.
Buffer/File | The path of the file that contains the JSON string.
JsonObject | The name of the parameter to store the handle of the JSON object.

lr_eval_json parses a JSON string, creates a JSON object, and stores the handle of the object in a parameter.

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

Note: Only ANSI and UTF-8 encodings are supported for this function.

## Return Values

This function returns 0 on success and -1 on failure.

## Parameterization

Parameterization is not applicable to this function.

## Example

This script shows the usage of lr_eval_json.

    TestEval()
    {
    	char* json_input = "{"
    		"\"firstName\": \"John\","
    		"\"lastName\": \"Smith\","
    		"\"address\": {"
    		"    \"streetAddress\":\"21 2nd Street\","
    		"    \"city\":\"New York\","
    		"    \"state\":\"NY\","
    		"    \"postalCode\":\"10021\""
    		"}"
    		"}";
    	lr_save_string(json_input, "JSON_Input_Param");

    	// Create a Json object from a string.
    	lr_eval_json("Buffer={JSON_Input_Param}",
    	             "JsonObject=json_obj_1", LAST);

    	// // Create a Json object from a file.
    	lr_eval_json("Buffer/File=store.json",
    	             "JsonObject=json_obj_2", LAST);

    	return 0;
    }

TestEval.c(16): Notify: Parameter Substitution: parameter "JSON_Input_Param" = "{"firstName": "John","lastName": "Smith","address": { "streetAddress":"21 2nd Street", "city":"New York", "state":"NY", "postalCode":"10021"}}"

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