How I convert string response into Array List

Waheed

I'm using websockets, and in the onMessage() method, I'm receiving a response in string form. I want to store this response in model class. How I convert this string response into array list?

[{"sender_id":"0008","created_at":"1313211849934","receiver_id":"0003","message":"second message","id":1,"chat_id":50,"type":"text"},{"sender_id":"0008","created_at":"1519211809934","receiver_id":"0003","message":"second message","id":2,"chat_id":50,"type":"text"}]
TanZhenxing
class Data {
  var sender_id:String? = null
  var created_at:String? = null
  var receiver_id:String? = null
  var message:String? = null
  var id:Int
  var chat_id:Long
  var type:String? = null
}

val jsonContent = "[{"sender_id":"0008","created_at":"1313211849934","receiver_id":"0003","message":"second message","id":1,"chat_id":50,"type":"text"},{"sender_id":"0008","created_at":"1519211809934","receiver_id":"0003","message":"second message","id":2,"chat_id":50,"type":"text"}]"
val data = new Gson().fromJson(jsonContent, Data:class.java)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

  1. 1

    How to return a single asset OhMyBrew Laravel Shopify

  2. 2

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    pump.io port in URL

  6. 6

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  7. 7

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  8. 8

    Make a B+ Tree concurrent thread safe

  9. 9

    Group boxplot data while keeping their individual X axis labels in ggplot2 in R

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  12. 12

    BigQuery - concatenate ignoring NULL

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  15. 15

    Razor Page - How to redirect to another folder's page using asp-for tag helper

  16. 16

    "django.db.utils.ProgrammingError: relation "auth_user" does not exist" Django V2.0

  17. 17

    How to exclude a specific git submodule from update?

  18. 18

    how to fix CMake Error in CMakeLists.txt: Generator NMake Makefiles does not support platform specification, but platform x64 was specified

  19. 19

    Is there a way to ask the user before loading the website

  20. 20

    How to remove the extra space from right in a webview?

  21. 21

    Optimising manipulation of large vectors

HotTag

Archive