Vue Js Convert JSON Object to String
.jpg)
Vue Js JSON.stringify(): Vue.js provides a built-in method called JSON.stringify(), which can be used to serialise JavaScript or objects into a JSON string representation. Here in this tutorial, we will learn how to convert a JSON object to a JSON string with the help of native Javascript and Vue JS.

written

reviewed

updated

Thanks for your feedback!
Your contributions will help us to improve service.
Vue Js JSON.stringify() Method Synatax
Copied to Clipboard
1
this.testString = JSON.stringify(this.testObj);
How to convert a JSON object to a string using Vue.js
In Vue.js, the JSON object can be converted to a string by using the "JSON.stringify()" function.With the our online editor, you can easily customize your code and see the results of your changes in real-time
Vue Js JSON.stringify() Method | Example
Copied to Clipboard
22
<div id="app">
<button @click="myFunction">click me</button>
<p>String:{{testString}}</p>
</div>
<script type="module">
import { createApp } from 'vue'
createApp({
data()
{
return{
testObj:{firstName: 'Andrew',lastName:'Roy',role:'developer'},
testString:''
}
},
methods:{
myFunction(){
this.testString = JSON.stringify(this.testObj);
},
}
}).mount('#app')
</script>
Output of above example
Ad