0

example:

<cc:attribute name="modelDTO" type="com.example.dto.ChartDTO"/>

and cc:implement

<cc:implement> 
   <script>
     var dto = '${cc.attrs.modelDTO}';
     console.log(dto);
   </script>
</cc:implement>

when i'm using this tag, i show log and get com.example.dto.ChartDTO@520ff6ee. so, how to parse dto to json in javascript?. i tried var json = JSON.parse(dto); but cann't

  • 1
    You need to take care of that on the server side. There are several libraries to serialize JSON (GSON, Jackson, etc). If you are using OmniFaces, you can use http://omnifaces.org/docs/javadoc/2.6/org/omnifaces/util/Json.html – Jasper de Vries Mar 29 '18 at 08:43
  • .. and there are many others that qualify as duplicate – Jasper de Vries Mar 29 '18 at 09:29

0 Answers0