Looking to convert a string of JavaScript objects into function arguments. The string format is as follows:
"{ "item1": "foo 1", "item2": "bar 1" }, { "item1": "foo 1", "item2": "bar 2" }"
While I can use JSON.parse to turn it into an array, the challenge lies in passing each object as separate arguments rather than as an array.
For example:
functionCall({ "item1": "foo 1", "item2": "bar 1" }, { "item1": "foo 1", "item2": "bar 2" });
The number of objects in the string is dynamic, making it difficult to determine how many arguments the function should accept.
I would prefer to group multiple objects under one variable and then pass that variable like so:
var objects = { "item1": "foo 1", "item2": "bar 1" }, { "item1": "foo 1", "item2": "bar 2" }
Is there a way to achieve this or any alternative approach available?