Is there a way to print the json representation of an object in a browser in Polymer?

In AngularJS, I would use:

<pre>{{object|json}}</pre>

Is there a way to do the same in PolymerJS?

+4
source share
2 answers

Implementing a custom filter is jsonpretty simple:

<script>
  PolymerExpressions.prototype.json = function(object) {
    return JSON.stringify(object);
  }
</script>

Then you can use {{object|json}}anywhere.

+5
source

I don’t think so that you can create a custom element and just make your object as follows:

JSON.stringify(object)
+2
source

All Articles