-2

There is one json object in .JS file of LWC component.

@track 
jsonVariable = {"type":"Payments","filter":{"currencies":[]}, "clientCode":230};

We want to render json data on HTML page.Like below,

enter image description here

JSON should be rendered in proper/ beautified manner. How to achieve this in LWC ? Thanks for help.

1
  • 1
    What have you tried? What doesn't work? Or at least, show us the URL you got the screenshot from so we can copy it for you...
    – zaitsman
    Commented May 3, 2022 at 1:10

1 Answer 1

0

I found below answer.It is working. We just have to make some changes as per LWC. For example, Instead of document.getElementById("json") use template.querySelector().

https://stackoverflow.com/questions/16862627/json-stringify-output-to-div-in-pretty-print-way

1
  • 1
    Could you please add the contents of the link to your answer and what exactly you did to make it work? Commented May 3, 2022 at 8:30

Not the answer you're looking for? Browse other questions tagged .