Git Product home page Git Product logo

Comments (3)

mdance avatar mdance commented on August 21, 2024

Here is the jsonapi body:

{
  "jsonapi": {
    "version": "1.0",
    "meta": {
      "links": {
        "self": {
          "href": "http://jsonapi.org/format/1.0/"
        }
      }
    }
  },
  "data": [
    {
      "type": "account--bank_account",
      "id": "redacted",
      "links": {
        "self": {
          "href": "redacted"
        }
      },
      "attributes": {
        "drupal_internal__id": 1,
        "name": "redacted",
        "status": true,
        "field_balance": 0,
        "field_hidden": false,
        "field_weight": 0
      },
      "relationships": {
        "field_account_status": {
          "data": {
            "type": "taxonomy_term--account_status",
            "id": "redacted",
            "meta": {
              "drupal_internal__target_id": 1
            }
          },
          "links": {
            "related": {
              "href": "redacted"
            },
            "self": {
              "href": "redacted"
            }
          }
        },
        "field_account_type": {
          "data": {
            "type": "taxonomy_term--account_type",
            "id": "redacted",
            "meta": {
              "drupal_internal__target_id": 1
            }
          },
          "links": {
            "related": {
              "href": "redacted"
            },
            "self": {
              "href": "redacted"
            }
          }
        },
        "field_currency": {
          "data": {
            "type": "taxonomy_term--currency",
            "id": "redacted",
            "meta": {
              "drupal_internal__target_id": 1
            }
          },
          "links": {
            "related": {
              "href": "redacted"
            },
            "self": {
              "href": "redacted"
            }
          }
        }
      }
    }
  ],
  "included": [
    {
      "type": "taxonomy_term--account_status",
      "id": "redacted",
      "links": {
        "self": {
          "href": "redacted"
        }
      },
      "attributes": {
        "drupal_internal__tid": 1,
        "status": true,
        "name": "Active",
        "description": null,
        "weight": 0
      }
    },
    {
      "type": "taxonomy_term--account_type",
      "id": "redacted",
      "links": {
        "self": {
          "href": "redacted"
        }
      },
      "attributes": {
        "drupal_internal__tid": 1,
        "status": true,
        "name": "Deposit",
        "description": null,
        "weight": 0
      }
    },
    {
      "type": "taxonomy_term--currency",
      "id": "redacted",
      "links": {
        "self": {
          "href": "redacted"
        }
      },
      "attributes": {
        "drupal_internal__tid": 1,
        "status": true,
        "name": "redacted",
        "description": null,
        "weight": 1,
        "field_currency_code": "redacted"
      }
    }
  ],
  "links": {
    "first": {
      "href": "redacted"
    },
    "next": {
      "href": "redacted"
    },
    "prev": {
      "href": "redacted"
    },
    "self": {
      "href": "redacted"
    }
  }
}

from jsonapi.

MarkoMilos avatar MarkoMilos commented on August 21, 2024

It is not possible to pass in plain Document type since Document<T> is generic.

For example, if you have a document of an article (standard example) it is not possible to pass the type of the Document like this

val type = Document::class.java

Nor you can do

val type = Article::class.java

Instead, you need to pass parameterized type

// Create a type for Document<Article>
val type = Types.newParameterizedType(Document::class.java, Article::class.java)
val articleAdapter: JsonAdapter<Document<Article>> = moshi.adapter(type)

In case you have a collection of articles then you can do it like this:

// Create a type for Document<List<Article>>
val type = Types.newParameterizedType(Document::class.java, Types.newParameterizedType(List::class.java, Article::class.java))
val articleAdapter: JsonAdapter<Document<List<Article>>> = moshi.adapter(type)

from jsonapi.

mdance avatar mdance commented on August 21, 2024

Thanks for your help, I've gotten things working

from jsonapi.

Related Issues (11)

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.