JsonApiNet icon indicating copy to clipboard operation
JsonApiNet copied to clipboard

How to map a relationship to the id property

Open opcodewriter opened this issue 8 years ago • 0 comments

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?

opcodewriter avatar Jul 08 '17 13:07 opcodewriter