Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
From a DX perspective, it would be a huge improvement if the "body" element could be a JSON object rather than a string.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2887388.patch | 1.99 KB | ziomizar |
Comments
Comment #2
e0ipsoThanks for dropping by @DamienMcKenna. Doing so would only make sense for JSON body responses, and Subrequests needs to stay agnostic.
You could add a new format
json_body
that inherits fromjson
to modify the response. Look intoMultiresponseJsonNormalizer
.If you end up implementing this, please contribute it as a patch. I think others will like this too.
Comment #3
ziomizar CreditAttribution: ziomizar at Station commented@e0ipso I tried to follow your suggestions and I did a first patch that create a new Normalizer json_body based on MultiresponseJsonNormalizer.
This approach reuse the output of MultiresponseJsonNormalizer and change just the body of each content response to json.
Comment #4
e0ipsoThat's pretty awesome @ziomizar. I'm not sure this is something it should live in this module or in the custom code on the site. In any case this is incredibly useful to people coming to find this feature.
Comment #6
e0ipsoI created an empty commit to appreciate your effort in doing this.
Comment #7
ziomizar CreditAttribution: ziomizar at Station commented@e0ipso many thanks!
I found this useful when i need to debug the output of subrequests or just read it.
If enough people start asking for a json_body format maybe you can add this to the module, anyway i can live also with this patch in composer or in a custom module.