I am looking to transform an object with various keys and values into a query string format, for example:
obj1: {
abc: "Abc",
id: 1,
address: "something"
}.
The challenge is that this object is generated dynamically, so the number of keys in it can vary. For instance, another dynamically created object could be:
obj1: {
test: "123",
test2: "3333"
}
No matter what the structure of the server's response object is, I need to convert it into a query string, like:
query1 = "test:'123'and test2: '3333'"
query2 = "abc:'Abc' and id: 1 and address: 'something'"
I could attempt something like:
Object.keys(obj1)[0]: obj1[Object.keys(obj1)[0]]
This approach would yield:
abc:'Abc'
However, due to the dynamic nature of the object's keys and length, I am struggling to figure out how to concatenate these pairs into a single string. Any suggestions?