question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get list of resources with different types?

See original GitHub issue

I have a json like this:

{
  "jsonapi": {
    "version": "1.0"
  },
  "meta": {
    "isNew": true
  },
  "data": [
    {
      "id": 4,
      "type": "user",
      "attributes": {
        "facebookId": "facebookId",
        "email": "email.abc@gmail.com",
        "name": "Lê Uyên Nguyễn",
        "avatar": "users/avatars/8c0f5fc9e15003b1692d564b5a009b00.jpg",
        "updated_at": "2016-08-22 23:30:11",
        "created_at": "2016-08-22 23:30:11",
        "loc": null
      }
    },
    {
      "id": "cfc60085d96d2bdb46ac719586fe8e28",
      "type": "accessToken",
      "attributes": {
        "tokenType": "Bearer",
        "value": "token-abc"
      }
    }
  ]
}

How can I get 2 resources (user and accessToken) in the array data?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kamikatcommented, Aug 23, 2016

Oh… I’m sorry.

Resource[] data = (Resource[]) moshi.adapter(Types.arrayOf(Resource.class)).fromJson(JSON);

The line comes from a test case for retrofit use which fails before 2.0.10 release. It should be ok to be replaced with following line:

Resource[] data = moshi.adapter(Resource[].class).fromJson(JSON);
1reaction
kamikatcommented, Aug 23, 2016

Hmm… I’ve tested your JSON against the library and everything just works fine https://gist.github.com/kamikat/24b08d3bfcb7ce964dd999c49a13ccaf

Is there any stacktrace about the problem?

Read more comments on GitHub >

github_iconTop Results From Across the Web

List all resources of a resource type - IBM
List all resources of a resource type. This command lists all resources of a given resource type that are available to a given...
Read more >
java - Returning different Resource type Lists from one method
>>. If I place question marks everywhere it lets me to run the program however then it returns the links with other fields...
Read more >
list-resource-types — AWS CLI 1.27.32 Command Reference
Specifies that you want the results to include only resources that have the specified scope. ALL – the results include both global and...
Read more >
List - REST API (Azure Resource Management) | Microsoft Learn
Learn more about Resource Management service - Get all the resources in a ... For example, to filter by a resource type, use...
Read more >
How to list all resources in your AWS account
You can select “All supported resource types” to get a broad overview of resources in specific AWS regions. At the time of writing,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found