How can I change the field output for JSON:API?

Created on 17 May 2022, about 2 years ago
Updated 18 October 2023, 8 months ago

Problem/Motivation

I'm using the JSON Field β†’ module and I have added a JSON field to my site. In the field settings, I set the field to "store as raw JSON in the database", but since I am using mariadb, it is actually stored as text.

The problem is that when I access this field via the core JSON:API, I get a string, not JSON. So I'm looking for a way to convert the string to "real" JSON before output by JSON:API.

I checked the customizing resources documentation β†’ but none of the methods there seemed like they would help in this case.

I'd appreciate it very much if someone could point to what I need to extend to get my JSON Field module JSON fields to automatically be output as JSON when accessed from JSON:API.

πŸ’¬ Support request
Status

Fixed

Version

9.5

Component
JSON APIΒ  β†’

Last updated 1 day ago

Created by

πŸ‡―πŸ‡΅Japan ptmkenny

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany ro-no-lo

    For anybody comming here from Google, like me, you can achieve this with the jsonapi_extras module. There is config page "JSON:API Resource overrides" were you can choose to override settings. To do so you choose the entity and click the override button. Then choose the json_raw field of your liking and go to "Advanced" and pick the enhancer "JSON Field".

    After that, at least for me, the result of an json_field in the JSON:API was pure JSON.

    (I still have to test, if the POST and PATCH will handle the pure JSON as well, but ready pure JSON is a great start)

Production build 0.69.0 2024