Currently, I am iterating through an array in Vue that contains objects with strings nested within. These objects have various properties such as idType, type, user, visibility, seller, product, company, and additionalData.
notifications: [
0: {
idType: 1
type: "delivered"
user: 12
visibility: true
seller: 15
product: "phone"
additionalData: "{"type":"iphone","idType":5,"number":"2"}"
}
1: {
idType: 2
type: "meeting"
user: 12
visibility: null
seller: 12
company: "hotell"
additionalData: "{"location":"office","idType":7,"number":"8"}"
}
2: {
idType: 1
type: "invoiced"
user: 15
visibility: null
seller: 11
value: 150000
additionalData: "{"payment":"credit","idType":10,"number":"1"}"
}
]
While parsing all the information from these additionalDatas, it becomes quite messy when done individually for each object in the template. To streamline this process, I intend to create a method for it.
I attempted to create a method like so:
parseText(type: string) {
return JSON.parse(this.note.additionalData).type
},
Unfortunately, this approach did not yield the desired result. I am currently passing 'note' to the parent component as a prop and also utilizing v-for in the parent component.