Schema::TYPE_JSON fields aren’t saved to the database as JSON #9040
-
DescriptionI’m building a custom field using the JSON schema type and, no matter what I do, I can’t get the value to save in the database as raw JSON without it being encoded. Currently data is encoded as I’ve tried a few things, including various encoding/decoding in both the Steps to reproduce
Additional info
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Craft doesn’t currently support JSON columns, since MySQL didn’t get support for them until 5.7.8, but Craft supports as far back as 5.5.0. If/when we bump our MySOL requirement, we can add support for it. In the meantime, you’ll just need to JSON-decode your values from Lines 373 to 376 in bfe9a55 |
Beta Was this translation helpful? Give feedback.
-
Ah, that would explain it. Thanks for the quick response, @brandonkelly. |
Beta Was this translation helpful? Give feedback.
-
Craft 4 is going to require MySQL 5.7.8+, so I’ve just added JSON support for it: #9089 |
Beta Was this translation helpful? Give feedback.
Craft 4 is going to require MySQL 5.7.8+, so I’ve just added JSON support for it: #9089