Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to json? #163

Closed
torian257x opened this issue Aug 18, 2020 · 2 comments
Closed

to json? #163

torian257x opened this issue Aug 18, 2020 · 2 comments

Comments

@torian257x
Copy link

hi, love the project!

I ran into this:

I want to have a

class Message{
    public MessageType $message_type;
    public string $message;
}

With:

namespace App\Enums;
use BenSampo\Enum\Enum;

/**
 * @method static static Success()
 * @method static static Error()
 */
final class MessageType extends Enum
{
    const Success =   'success';
    const Error =   'error';
}

when casting to json I want to get

{message: 'adfsadsf adfs asdf ', message_type: 'success'}

what I get instead is

[{"message_type":{"value":"success","key":"Success","description":"Success"},"message":"Successfully added matrix entries"}]

any shortcut or something?

@atymic
Copy link
Contributor

atymic commented Aug 18, 2020

Looks to be a duplicate of #162

BenSampo added a commit that referenced this issue Aug 30, 2020
…ribute casting serialization expectations. Solves #163 #162
@BenSampo
Copy link
Owner

@jossnaz This should be fixed in v2.2.0. Can you upgrade and try again? Let me know if you're still having issues.

atymic pushed a commit to atymic/laravel-enum that referenced this issue Oct 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants