Using lr_json_set_values to set value of property to a parameter that happens to contain valid json

I saw another question related to this, but I don't believe the accepted answer was adequate. It appears that lr_json_set_values behaves differently if the value you provide is a string that happens to be valid json vs. if it is not. Maybe this is because there's no function to set the value of a property to a json object and so this function has to do double duty, handling strings and strings that could be json objects. In any case if I pass a string to the function, it should behave the same way, whether or not that string happens to be valid json. There should be another function to set a value to a json object.

{
  "property": "value"
}

As it is, there appears to be no way to set the value of the property above to something like "{\"data\":{}}" without writing your own function.

lr_save_string("{\"property\":\"value\"}", "string_1");
    
    lr_save_string("{\"data\":{}}", "Valid_Json_String_Containing_Double_Quote");
    
    lr_save_string("{\"data\":{}}_", "Invalid_Json_String_Containg_Double_Quote");
    

    lr_eval_json("Buffer={string_1}",
                 "JsonObject=json_obj_1", LAST);
    
    lr_eval_json("Buffer={string_1}",
                 "JsonObject=json_obj_2", LAST);

    
    lr_json_set_values("JsonObject=json_obj_1",
                    "ValueParam=Valid_Json_String_Containing_Double_Quote",
                    "QueryString=$.property",
                     LAST);
    
    //expected: string_1 = {"property":"{\"data\":{}}"}
    //observed: string_1 = {"property":{"data":{}}}
    lr_json_stringify("JsonObject=json_obj_1",
                      "Format=compact",
                      "OutputParam=string_1",LAST );
                      
    lr_json_set_values("JsonObject=json_obj_2",
                    "ValueParam=Invalid_Json_String_Containg_Double_Quote",
                    "QueryString=$.property",
                     LAST);
    
    //expected: string_2 = {"property":"{\"data\":{}}_"}
    //observed: string_2 = {"property":"{\"data\":{}}_"}
    lr_json_stringify("JsonObject=json_obj_2",
                      "Format=compact",
                      "OutputParam=string_2",LAST );

Is there any way to do this without using a custom function as described here?

community.microfocus.com/.../replace-json-object-value-with-another-json

Tags: