Skip to content

Bug: ResourceController json response always empty #2617

Description

@benrogmans

When creating a ResourceController, following the documentation any json response will be empty. This is because json_encode() can not handle the \CodeIgniter\Entity class automatically.

Proposed solution
\CodeIgniter\Entity to implement \JsonSerializable and the method jsonSerialize() to return its attributes.

CodeIgniter 4 version
4.0.2

Affected module(s)
system/Entity.php

Expected behavior, and steps to reproduce if appropriate
Following the user guide I would expect to get a json result instead of an empty response.

Context

  • macOS
  • php spark serve
  • PHP version 7.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions