JsonApiNet
JsonApiNet copied to clipboard
How to map a relationship to the id property
Imagine a simple relationship where a Foo has a Boo:
"data": [
{
"id": "1",
"type": "foos",
"relationships": {
"bar" : {
data: {
"type": "bars",
"id": "1"
}
}
}
}
What I'd like is to be able to deserialize Foo's "bar" relationship to the id, not to the full object.
See the comment for the Bar property below:
class Foo
{
public int Id { get; set; }
public Bar Bar { get; set; } // instead, I would like to have this: public int BarId { get; set; }
}
class Bar
{
public int Id { get; set; }
}
How can I do this?