Coder Social home page Coder Social logo

jsonapinet's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsonapinet's Issues

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?

ResourceFromDocument doesn't work when types in Json are not plural

Hi,
I'm using JsonApiNet to deserialize a compound Json document, however the data types in the Json are singular rather than plural (e.g. "vendor" rather than "vendors"). This causes an error when calling JsonApi.ResourceFromDocument. Am I missing something? If I change the data types to plurals (i.e. vendors, addresses and contacts) it works fine. I do not have control over the generation of the Json.

I have attached the Json that does not work.

Many thanks,

Phil

VendorJson - with singular types.txt

how to map complex types in Attribute

how to map "name" complex type in attributes with my own class

class

`public class SubscriptionType
{
public string Id { get; set; }

    public string BusinessModelType { get; set; }

    //[JsonApiRelationship("name")] // [JsonApiAttribute("name")] //not working
    public Name Name;   
}`

public class Name { public string En { get; set; } public string Ur { get; set; } }

json
{ "data": [ { "attributes": { "business-model-type": "prepaid", "name": { "en": "Start prepaid", "ur": "Start Prepaid" } }, "id": "1", "links": { "self": "/api/v1/subscription-types/1" }, "relationships": { "billing-rate-plans": { "links": { "related": "/api/v1/subscription-types/1/billing-rate-plans" } } }, "type": "subscription-types" } ] }

JsonApiNet set property with no setter

Shaun, I submitted a PR for a bug fix that we have encountered. The issue is that if you pass a document that has an attribute that maps to a POCO property with no setter, a null reference exception occurs. We would expect the deserializer to just bypass the property. In this case the property with no setter has a getter from another property so when accessed, it actually has a value, just not the value in the original document.

License change

Hi, we are evaluating to use this library in a commercial product but the GPL v2 license does not permit us to use it. Have you any plan to change the license in a MIT or Apache like one?

How to prevent infinite recursion?

I have Foo which has a relationship of several Boo, but Boo also has a relationship with Foo.
This creates a stack overflow due to infinite recursion.

Is there a way to prevent this?

Enum properties are converted to strings, not to integers

Enum properties are converted to strings, not to integers.

For example, if I have

class MyItem
{
      public int Id { get; set; }
      public MyItemStatus Status { get; set; }
}

enum MyItemStatus 
{
        Good,
        Great
}

When serializing, it will write "good" or "great" not 0 or 1

The documentation says

Note: This is using Json.NET under the hood, so you can map complex objects from your "attributes" values using [JsonProperty], specify a custom JsonConverter on them, etc.!

so I tried this:

class MyItem
{
      public int Id { get; set; }

      [JsonConverter(typeof(IntEnumConverter)]
      public MyItemStatus Status { get; set; }
}

but converter is not being called on serialization

How to serialize?

I love your library, I like how type and property resolvers work, especially since I don't like using attributes on POCO.

Any example how to serialize a resource object?

You mention in the README that "There are a couple alternative serializers for JSON API ".
So one is JsonApiMediaTypeFormatter, which is the other one?

I'm trying to wrap my head around JsonApiMediaTypeFormatter with no luck yet.

By the way I was able to convert the library into a PCL let me know if you're interested about that. It's pretty easy to do it, it's mostly about replacing reflection APIs with the ones from shared .NET.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.