Skip to content
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

Failed to parse "link" inside "included" property #28

Open
adhityasp opened this issue Aug 4, 2022 · 1 comment
Open

Failed to parse "link" inside "included" property #28

adhityasp opened this issue Aug 4, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@adhityasp
Copy link

Background

I want to parse JSON that has "link" inside "included" array. this is the example:

{
  "data": [
    {
      "type": "article",
      "id": "1",
      "attributes": {
        "title": "sample-title",
      },
      "relationships": {
        "author": {
          "data": {
            "type": "people",
            "id": "9"
          }
        }
      },
      "links": {
        "self": "http://example.com/articles/1"
      }
    }
  ],
  "included": [
    {
      "type": "people",
      "id": "9",
      "attributes": {
        "name": "Dan",
        "lastName": "Gebhardt",
        "twitter": "dgeb"
      },
      "links": { when this links is removed, the parsing works just fine
        "self": "http://example.com/people/9",
        "next": "http://example.com/articles?page[offset]=2"
      }
    }
  ]
}

When i parse that json string, i encountered this error

Polymorphic serializer was not found for missing class discriminator ('null')
JSON input: {"self":"http://example.com/people/9","next":"http://example.com/articles?page[offset]=2"}
kotlinx.serialization.json.internal.JsonDecodingException: Polymorphic serializer was not found for missing class discriminator ('null')
JSON input: {"self":"http://example.com/people/9","next":"http://example.com/articles?page[offset]=2"}
	at app//kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24)
	at app//kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32)
	at app//kotlinx.serialization.json.internal.PolymorphicKt.throwSerializerNotFound(Polymorphic.kt:76)

Questions:

Do you have any idea about this ? I also checking your sample project and i added the "link" inside the "included property" on "person_list.json", the error message is the same with my error.

@stjepanbanek stjepanbanek added the enhancement New feature or request label Aug 5, 2022
@stjepanbanek stjepanbanek self-assigned this Aug 5, 2022
@stjepanbanek
Copy link
Contributor

stjepanbanek commented Aug 5, 2022

Hi @adhityasp and thanks for your effort and feedback!
For the time being, serializing and deserializing links in the included array is not supported. This is because the feature is fairly complex, so we postponed implementing it for a future release of the library.

By the time we make a stable release, links in included blocks will be supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants