Tridion Asked by NewUser on March 5, 2021
In our implementation of the DXA web app, most of the times we encounter scenarios where the Components are not having content in all the fields.
Hence the JSON response also are not fetching the fields, as they are blank. And in the web app frontend we need to still check these fields to prevent exceptions.
I would like to know, if there is a way to get a consistent JSON structure, even if the Component fields are empty, so that we can reduce the frontend checks.
If you’re talking about the JSON representation of your Strongly Typed Models, you are not really talking about Component fields anymore, but about the properties (data fields) of your Strongly Typed Model and the way these are serialized to JSON.
If a Component field has no values, the associated Model property will be null
(depending on its type).
AFAIK, null
values are serialized by default, but this is a setting of the JSON serializer. Frankly, I don’t know how this works exactly in DXA Java / Spring MVC.
Answered by Rick Pannekoek on March 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP