Try this:
this.content = JSON.parse(content);
This will give you an array, which you can then iterate over.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all
I am trying to parse a JSON string that my Laravel application serves to my Vue view. The JSON string can look like this:
{
"1":[
{
"row":"Some text here on first column."
},
{
"row":"And more text. Second row."
},
{
"row":"Text!"
}
],
"2":[
{
"row":"2nd column text."
},
{
"row":""
}
],
"3":[
{
"row":"Even more text. But on the third column."
}
]
}
Things to note here:
I am trying to parse the string as a table, like: https://jsfiddle.net/59bz2hqs/1/.
This is what I have now:
<template>
<div>
<table>
<tbody>
<tr v-for="row in this.content">
<td>{{row}}</td>
</tr>
</tbody>
</table>
<div>
</template>
<script>
export default {
data() {
return {
content: []
}
},
created() {
Event.$on("document-was-processed", content => {
this.content = content;
});
}
}
</script>
Now above simply prints out the actual JSON string. Can anyone help me out on how to actually parse the content?
Thanks!
Please or to participate in this conversation.