nilportugues / symfony-jsonapi

JSON API Transformer Bundle for Symfony 2 and Symfony 3
http://nilportugues.com
MIT License
115 stars 19 forks source link

Serializing DateTime objects? #2

Closed drewclauson closed 8 years ago

drewclauson commented 8 years ago

How do I serialize a DateTime property? When I do so from a Doctrine entity, I get the following:

Notice: Undefined index: DateTime (500 Internal Server Error)
nilportugues commented 8 years ago

Actually this is a bug. I just wrote the fix for it at: https://github.com/nilportugues/jsonapi-transformer/commit/16cc089912153af22450344953357067d995a1b2

Let me create a release for this fix and I'll close the issue.

nilportugues commented 8 years ago

OK release is ready!

make sure to use composer require nilportugues/json-api:1.0.24

Thanks for reporting :+1: !

drewclauson commented 8 years ago

:+1: Thanks, I'll look into testing it tomorrow.

drewclauson commented 8 years ago

FYI, the name of the attribute stays camelCased instead of dasherized.

Example from actual output:

        "modifiedAt": {
          "date": "2011-09-07 00:00:00.000000",
          "timezone_type": 3,
          "timezone": "GMT"
        },
        "created_by_user": 0,
        "modified_by_user": 0
nilportugues commented 8 years ago

hmm this needs fixing and it's easy to fix. Let me do it!

nilportugues commented 8 years ago

@drewclauson fix included in nilportugues/json-api:1.0.25

Thanks again for spotting this tiny things! :)