Jump to content

Decoding JSON Data from a field returns "null"


Stefanowitsch
 Share

Recommended Posts

I have a trivial problem that is driving me insane.

I am saving JSON Data into a field:

$groupOverview->json_calendar_data = json_encode($eventsData);
$groupOverview->save();

image.thumb.png.ffa1b7ed5c54d02762bfb6bafe45feba.png

The JSON string is valid, as I have testet.

In the frontend I turn this string back into an array like this:

$eventsData = json_decode($groupOverview->json_calendar_data, true);
bd($eventsData);

The problem is: It always returns NULL.

Printing out the field value as string works fine though, this is not a field selector issue.

image.png.76716c2787e21a984ba9d5ef2a0f7ac2.png

Link to comment
Share on other sites

14 minutes ago, virtualgadjo said:

hi,

looking at your dump, it sounds more like a htmlspecialchars encoding, you may either remove it from the field setting or use htmlspecialchars_decode on the output before json_decode 🙂

have a nice day

Thanks! You are right. After removing the HTML Entity Encoder Text Formatter form the field the decoding works.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...