Skip to content

Instantly share code, notes, and snippets.

@arvidkahl
Created February 17, 2017 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvidkahl/7d1c9b317d07f2700231eb35d212e812 to your computer and use it in GitHub Desktop.
Save arvidkahl/7d1c9b317d07f2700231eb35d212e812 to your computer and use it in GitHub Desktop.
JSON Tree View Basic HTML
<div class="container" id="vue-root">
<div class="row">
<div class="col-xs-12">
<h1>A JSON Tree View Component in Vue.js</h1>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<pre><code>{{formatJSON(sampleData)}}</code></pre>
</div>
<div class="col-xs-6">[Tree View]</div>
</div>
</div>
new Vue({
el: "#vue-root",
methods: {
// return pretty-printed JSON
formatJSON: function(theJSON){
return JSON.stringify(theJSON, true, 2);
}
},
data: function(){
return {
// Returns a JSON object with common
// data structures, such as Arrays,
// Objects and raw Values
sampleData: {"a":"b","c":[{"a":"b"},{"c":"d","e":"f"}],"d":{"a":"b","c":1234,"d":[1,"a",{"c":"d"}]},"g":null,"h":3.1415}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment