I have an object and I would like to convert the contents of the object as a string to first array element value , key of the array will be 0
example: I have
const obj1= {
all-exception: []
root-exception: "java.util.concurrent.CompletionExceptionn"
timestamp: 1671113624318
truncated: false
}
I would like to see the result as :
const obj2=
0: "{"all-exceptions":[],"root-exception":"java.util.concurrent.CompletionException\n","timestamp": 1671113624318,"truncated":false}”
Advertisement
Answer
You can use the
const obj = {
'all-exception': [],
'root-exception': "java.util.concurrent.CompletionExceptionn",
timestamp: 1671113624318,
truncated: false
};
console.log([JSON.stringify(obj)]);JSON.stringify method: