From a DX perspective, it would be a huge improvement if the "body" element could be a JSON object rather than a string.

CommentFileSizeAuthor
#3 2887388.patch1.99 KBziomizar
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna created an issue. See original summary.

e0ipso’s picture

Thanks 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 from json to modify the response. Look into MultiresponseJsonNormalizer.

If you end up implementing this, please contribute it as a patch. I think others will like this too.

ziomizar’s picture

Status: Active » Needs review
FileSize
1.99 KB

@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.

e0ipso’s picture

That'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.

  • e0ipso committed 32ae6d2 on 8.x-2.x authored by ziomizar
    Issue #2887388 by ziomizar, e0ipso: Allow "body" element to be an object
    
e0ipso’s picture

Status: Needs review » Fixed

I created an empty commit to appreciate your effort in doing this.

ziomizar’s picture

@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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.