1

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.

2
  • Which JSON structure are you talking about, exactly? The DXA R2 JSON which is used to publish data from CM to CD? Or the JSON representation of your Strongly Typed Models? Commented Feb 14, 2019 at 16:21
  • the JSON representation of the Strongly Typed Models
    – NewUser
    Commented Feb 15, 2019 at 9:50

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.