-
Notifications
You must be signed in to change notification settings - Fork 18
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
How to avoid serializing compound objects? #20
Comments
Anyone else with the same issue? |
@franbenz map it as a plain array. But the standard uses included for a reason. |
Thanks. Is there a doc about mappings? |
@franbenz A doc about mappings for this library you mean? |
@nilportugues Yes, I can't find how to map a doctrine entity to a plain array in the yml mappings from this library. |
There's no need to map arrays, the serializer will pick them up |
@nilportugues Serialization:
The $newObra array from doctrine looks like this:
|
Mind updating to 1.4.0? I've applied some changes to the underlying lib that should fix this. |
Hi @nilportugues . After the update to 1.4.0. the json-api package was updated. But I'm still getting "Undefined index: @type" when serializing the array generated by doctrine. |
@franbenz thanks for the patience. Try this. As it has Write a mapper for it and let me know if it solves the problem. |
The array I'm getting from Doctrine is not really an ArrayCollection, please look the var_dump from my previous comment. It does not include any class or type information.
|
@franbenz I can fix it. Give me second. |
@franbenz fetch new version with |
The undefined index notice is still occurring(empty function must receive a variable and not an expression). We've corrected it here, but now it happens in setResponseDataAttributes in vendor\nilportugues\json-api\src\Helpers\DataAttributesHelper.php at line 100. We don't know what should this function do when there is no type. |
Mind sharing the object structure? Nestings, etc etc? The code should not take you to |
This is what the builtin serialize function from php returns for the array I'm passing to the serialize function from the json-api library. It's just an array:
This array was obtained from |
@franbenz did you find a solution for these or I need to look into it? |
For now we've stopped using these arrays serializations, though probably still a bug. There's just no hurry right now. Thanks Nil! |
Hi Nil. Is there a way to avoid using the top-level
included
member?Here is an example:
If I'm forced to use the
included
member, to avoid the doctrine closure issue, then every time I request an Invoice_detail to the jsonapi I would have to include in the request the Invoice and the Customer. Is this approach the right way to use the API?The text was updated successfully, but these errors were encountered: