Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

API results contain a whole lot of needless boilerplate #14

Open
the-daniel-rothig opened this issue Feb 22, 2018 · 2 comments
Open

API results contain a whole lot of needless boilerplate #14

the-daniel-rothig opened this issue Feb 22, 2018 · 2 comments

Comments

@the-daniel-rothig
Copy link
Contributor

The API result objects contain $id and $ref entries, as well as a lot of nullable fields.

The expected behaviour is that they only contain non-null entries except where it makes sense, and no random metadata injected by ASP.NET

@ashleybaldock
Copy link
Contributor

The $id and $ref entries are due to serialising cyclical data structures and wanting to be able to decode them into the same structure at the other end - there's a fairly simple toggle which you can set which changes the behaviour to not do this, but then you don't get any of the cyclical references (and the data returned balloons somewhat in size).

Is this really the expected behaviour? We haven't really specced out what we want the API to do aside from be consumed by our application. Obviously all things are possible though...

Skipping null fields is plausibly easy enough to do.

@ashleybaldock
Copy link
Contributor

https://abhishekcgh.wordpress.com/2014/04/26/serializing-json-data-with-cyclic-references/ - the $id/$ref are just Newtonsoft's JSON lib's way of handling this stuff (https://www.newtonsoft.com/json/help/html/PreserveObjectReferences.htm) - you can write your own deserialiser to handle this data format. Isn't ASP.NET metadata :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants