Android Kotlin JSONObject cannot be cast












0















I am trying to convert a JSON string into a JSON data class object. The compiler does not complain, the Android Studio 3 IDE provides the necessary hints to correct code. Still I get a runtime error saying that JSONObject cannot be cast. Please any hints...



I have the following code:



fun startReplay() {
doAsync {
triggerServerFile(eventDomain + "/get-replay-JSON.php")
val jsonString = getServerFile(eventDomain + "/data/replay-SidR2018.json?nocache=" + Math.random())
uiThread {
var replayData:replayDataObject = JSONObject(jsonString) as replayDataObject
val a= replayData.component1()
val b= replayData.component2()[3].component3()
}
}
}


and the following data classes:



data class replayDataObject(
val event: String,
val shiptracks: List<Shiptrack>,
val windtracks: List<Windtrack>
)

data class Shiptrack(
val colorcode: String,
val course: List<String>,
val lat: List<String>,
val lon: List<String>,
val name: String,
val speed: List<String>,
val stamp: List<String>
)

data class Windtrack(
val course: List<String>,
val lat: List<String>,
val lon: List<String>,
val name: String,
val speed: List<String>,
val stamp: List<String>
)


and finally the following JSON string:



{
"event": "SidR2018,Slag in de Rondte 2018",
"shiptracks": [{
"name": "Hollandia",
"colorcode": "0",
"stamp": ["1541407570", "1541407599"],
"lat": ["53.173461666667", "53.17347"],
"lon": ["5.409655", "5.409655"],
"speed": ["0", "0"],
"course": ["299", "301"]
}, {
"name": "Ouderzorg",
"colorcode": "14",
"stamp": ["1541407540", "1541407540", "1541407540"],
"lat": ["53.17359", "53.17359", "53.17359"],
"lon": ["5.409586", "5.409586", "5.409586"],
"speed": ["0", "0", "0"],
"course": ["0", "0", "0"]
}
],
"windtracks": [{
"name": "Arcen",
"stamp": ["1541409000", "1541411400"],
"lat": ["51.5", "51.5"],
"lon": ["6.2", "6.2"],
"speed": ["4", "2"],
"course": ["72", "61"]
}, {
"name": "Zeeplatform K13",
"stamp": ["1541408400", "1541410800", "1541412000", "1541414400"],
"lat": ["53.22", "53.22", "53.22", "53.22"],
"lon": ["3.22", "3.22", "3.22", "3.22"],
"speed": ["16", "16", "17", "16"],
"course": ["126", "129", "127", "120"]
}
]
}


The stack trace (line 381 is the line in the code containing JSOBObject:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: nl.zeilvaartwarmond.ttandroid.szwtracktrace, PID: 23370
java.lang.ClassCastException: org.json.JSONObject cannot be cast to nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$replayDataObject
at nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$startReplay$1$1.invoke(MapsActivity.kt:381)
at nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$startReplay$1$1.invoke(MapsActivity.kt:44)
at org.jetbrains.anko.AsyncKt$uiThread$1.run(Async.kt:70)
at android.os.Handler.handleCallback(Handler.java:898)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6716)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)










share|improve this question

























  • Post the stack trace, it'll probably tell you what can't be cast

    – Speed
    Nov 24 '18 at 20:30






  • 4





    You can't just cast a JSONObject to whatever you want. You have to manually populate a new instance of your data class with the values in the JSONObject.

    – TheWanderer
    Nov 24 '18 at 20:32











  • Stacktrace added.

    – HWK
    Nov 24 '18 at 20:36






  • 1





    As @TheWanderer already stated, the compiler has no idea how to convert from JSONObject to replayDataObject. You must by hand create a conversion function (preferably an additional constructor for replayDataObject) which takes the wanted data out of the JSONObject and calls replayDataObject's primary constructor to place the data in its fields.

    – Michael Butscher
    Nov 24 '18 at 21:34






  • 1





    The IDE plugin seems not to provide such functionality. I don't know which other "software" you may mean.

    – Michael Butscher
    Nov 24 '18 at 22:03


















0















I am trying to convert a JSON string into a JSON data class object. The compiler does not complain, the Android Studio 3 IDE provides the necessary hints to correct code. Still I get a runtime error saying that JSONObject cannot be cast. Please any hints...



I have the following code:



fun startReplay() {
doAsync {
triggerServerFile(eventDomain + "/get-replay-JSON.php")
val jsonString = getServerFile(eventDomain + "/data/replay-SidR2018.json?nocache=" + Math.random())
uiThread {
var replayData:replayDataObject = JSONObject(jsonString) as replayDataObject
val a= replayData.component1()
val b= replayData.component2()[3].component3()
}
}
}


and the following data classes:



data class replayDataObject(
val event: String,
val shiptracks: List<Shiptrack>,
val windtracks: List<Windtrack>
)

data class Shiptrack(
val colorcode: String,
val course: List<String>,
val lat: List<String>,
val lon: List<String>,
val name: String,
val speed: List<String>,
val stamp: List<String>
)

data class Windtrack(
val course: List<String>,
val lat: List<String>,
val lon: List<String>,
val name: String,
val speed: List<String>,
val stamp: List<String>
)


and finally the following JSON string:



{
"event": "SidR2018,Slag in de Rondte 2018",
"shiptracks": [{
"name": "Hollandia",
"colorcode": "0",
"stamp": ["1541407570", "1541407599"],
"lat": ["53.173461666667", "53.17347"],
"lon": ["5.409655", "5.409655"],
"speed": ["0", "0"],
"course": ["299", "301"]
}, {
"name": "Ouderzorg",
"colorcode": "14",
"stamp": ["1541407540", "1541407540", "1541407540"],
"lat": ["53.17359", "53.17359", "53.17359"],
"lon": ["5.409586", "5.409586", "5.409586"],
"speed": ["0", "0", "0"],
"course": ["0", "0", "0"]
}
],
"windtracks": [{
"name": "Arcen",
"stamp": ["1541409000", "1541411400"],
"lat": ["51.5", "51.5"],
"lon": ["6.2", "6.2"],
"speed": ["4", "2"],
"course": ["72", "61"]
}, {
"name": "Zeeplatform K13",
"stamp": ["1541408400", "1541410800", "1541412000", "1541414400"],
"lat": ["53.22", "53.22", "53.22", "53.22"],
"lon": ["3.22", "3.22", "3.22", "3.22"],
"speed": ["16", "16", "17", "16"],
"course": ["126", "129", "127", "120"]
}
]
}


The stack trace (line 381 is the line in the code containing JSOBObject:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: nl.zeilvaartwarmond.ttandroid.szwtracktrace, PID: 23370
java.lang.ClassCastException: org.json.JSONObject cannot be cast to nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$replayDataObject
at nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$startReplay$1$1.invoke(MapsActivity.kt:381)
at nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$startReplay$1$1.invoke(MapsActivity.kt:44)
at org.jetbrains.anko.AsyncKt$uiThread$1.run(Async.kt:70)
at android.os.Handler.handleCallback(Handler.java:898)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6716)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)










share|improve this question

























  • Post the stack trace, it'll probably tell you what can't be cast

    – Speed
    Nov 24 '18 at 20:30






  • 4





    You can't just cast a JSONObject to whatever you want. You have to manually populate a new instance of your data class with the values in the JSONObject.

    – TheWanderer
    Nov 24 '18 at 20:32











  • Stacktrace added.

    – HWK
    Nov 24 '18 at 20:36






  • 1





    As @TheWanderer already stated, the compiler has no idea how to convert from JSONObject to replayDataObject. You must by hand create a conversion function (preferably an additional constructor for replayDataObject) which takes the wanted data out of the JSONObject and calls replayDataObject's primary constructor to place the data in its fields.

    – Michael Butscher
    Nov 24 '18 at 21:34






  • 1





    The IDE plugin seems not to provide such functionality. I don't know which other "software" you may mean.

    – Michael Butscher
    Nov 24 '18 at 22:03
















0












0








0








I am trying to convert a JSON string into a JSON data class object. The compiler does not complain, the Android Studio 3 IDE provides the necessary hints to correct code. Still I get a runtime error saying that JSONObject cannot be cast. Please any hints...



I have the following code:



fun startReplay() {
doAsync {
triggerServerFile(eventDomain + "/get-replay-JSON.php")
val jsonString = getServerFile(eventDomain + "/data/replay-SidR2018.json?nocache=" + Math.random())
uiThread {
var replayData:replayDataObject = JSONObject(jsonString) as replayDataObject
val a= replayData.component1()
val b= replayData.component2()[3].component3()
}
}
}


and the following data classes:



data class replayDataObject(
val event: String,
val shiptracks: List<Shiptrack>,
val windtracks: List<Windtrack>
)

data class Shiptrack(
val colorcode: String,
val course: List<String>,
val lat: List<String>,
val lon: List<String>,
val name: String,
val speed: List<String>,
val stamp: List<String>
)

data class Windtrack(
val course: List<String>,
val lat: List<String>,
val lon: List<String>,
val name: String,
val speed: List<String>,
val stamp: List<String>
)


and finally the following JSON string:



{
"event": "SidR2018,Slag in de Rondte 2018",
"shiptracks": [{
"name": "Hollandia",
"colorcode": "0",
"stamp": ["1541407570", "1541407599"],
"lat": ["53.173461666667", "53.17347"],
"lon": ["5.409655", "5.409655"],
"speed": ["0", "0"],
"course": ["299", "301"]
}, {
"name": "Ouderzorg",
"colorcode": "14",
"stamp": ["1541407540", "1541407540", "1541407540"],
"lat": ["53.17359", "53.17359", "53.17359"],
"lon": ["5.409586", "5.409586", "5.409586"],
"speed": ["0", "0", "0"],
"course": ["0", "0", "0"]
}
],
"windtracks": [{
"name": "Arcen",
"stamp": ["1541409000", "1541411400"],
"lat": ["51.5", "51.5"],
"lon": ["6.2", "6.2"],
"speed": ["4", "2"],
"course": ["72", "61"]
}, {
"name": "Zeeplatform K13",
"stamp": ["1541408400", "1541410800", "1541412000", "1541414400"],
"lat": ["53.22", "53.22", "53.22", "53.22"],
"lon": ["3.22", "3.22", "3.22", "3.22"],
"speed": ["16", "16", "17", "16"],
"course": ["126", "129", "127", "120"]
}
]
}


The stack trace (line 381 is the line in the code containing JSOBObject:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: nl.zeilvaartwarmond.ttandroid.szwtracktrace, PID: 23370
java.lang.ClassCastException: org.json.JSONObject cannot be cast to nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$replayDataObject
at nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$startReplay$1$1.invoke(MapsActivity.kt:381)
at nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$startReplay$1$1.invoke(MapsActivity.kt:44)
at org.jetbrains.anko.AsyncKt$uiThread$1.run(Async.kt:70)
at android.os.Handler.handleCallback(Handler.java:898)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6716)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)










share|improve this question
















I am trying to convert a JSON string into a JSON data class object. The compiler does not complain, the Android Studio 3 IDE provides the necessary hints to correct code. Still I get a runtime error saying that JSONObject cannot be cast. Please any hints...



I have the following code:



fun startReplay() {
doAsync {
triggerServerFile(eventDomain + "/get-replay-JSON.php")
val jsonString = getServerFile(eventDomain + "/data/replay-SidR2018.json?nocache=" + Math.random())
uiThread {
var replayData:replayDataObject = JSONObject(jsonString) as replayDataObject
val a= replayData.component1()
val b= replayData.component2()[3].component3()
}
}
}


and the following data classes:



data class replayDataObject(
val event: String,
val shiptracks: List<Shiptrack>,
val windtracks: List<Windtrack>
)

data class Shiptrack(
val colorcode: String,
val course: List<String>,
val lat: List<String>,
val lon: List<String>,
val name: String,
val speed: List<String>,
val stamp: List<String>
)

data class Windtrack(
val course: List<String>,
val lat: List<String>,
val lon: List<String>,
val name: String,
val speed: List<String>,
val stamp: List<String>
)


and finally the following JSON string:



{
"event": "SidR2018,Slag in de Rondte 2018",
"shiptracks": [{
"name": "Hollandia",
"colorcode": "0",
"stamp": ["1541407570", "1541407599"],
"lat": ["53.173461666667", "53.17347"],
"lon": ["5.409655", "5.409655"],
"speed": ["0", "0"],
"course": ["299", "301"]
}, {
"name": "Ouderzorg",
"colorcode": "14",
"stamp": ["1541407540", "1541407540", "1541407540"],
"lat": ["53.17359", "53.17359", "53.17359"],
"lon": ["5.409586", "5.409586", "5.409586"],
"speed": ["0", "0", "0"],
"course": ["0", "0", "0"]
}
],
"windtracks": [{
"name": "Arcen",
"stamp": ["1541409000", "1541411400"],
"lat": ["51.5", "51.5"],
"lon": ["6.2", "6.2"],
"speed": ["4", "2"],
"course": ["72", "61"]
}, {
"name": "Zeeplatform K13",
"stamp": ["1541408400", "1541410800", "1541412000", "1541414400"],
"lat": ["53.22", "53.22", "53.22", "53.22"],
"lon": ["3.22", "3.22", "3.22", "3.22"],
"speed": ["16", "16", "17", "16"],
"course": ["126", "129", "127", "120"]
}
]
}


The stack trace (line 381 is the line in the code containing JSOBObject:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: nl.zeilvaartwarmond.ttandroid.szwtracktrace, PID: 23370
java.lang.ClassCastException: org.json.JSONObject cannot be cast to nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$replayDataObject
at nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$startReplay$1$1.invoke(MapsActivity.kt:381)
at nl.zeilvaartwarmond.ttandroid.szwtracktrace.MapsActivity$startReplay$1$1.invoke(MapsActivity.kt:44)
at org.jetbrains.anko.AsyncKt$uiThread$1.run(Async.kt:70)
at android.os.Handler.handleCallback(Handler.java:898)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6716)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)







android json kotlin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 20:35







HWK

















asked Nov 24 '18 at 20:26









HWKHWK

294




294













  • Post the stack trace, it'll probably tell you what can't be cast

    – Speed
    Nov 24 '18 at 20:30






  • 4





    You can't just cast a JSONObject to whatever you want. You have to manually populate a new instance of your data class with the values in the JSONObject.

    – TheWanderer
    Nov 24 '18 at 20:32











  • Stacktrace added.

    – HWK
    Nov 24 '18 at 20:36






  • 1





    As @TheWanderer already stated, the compiler has no idea how to convert from JSONObject to replayDataObject. You must by hand create a conversion function (preferably an additional constructor for replayDataObject) which takes the wanted data out of the JSONObject and calls replayDataObject's primary constructor to place the data in its fields.

    – Michael Butscher
    Nov 24 '18 at 21:34






  • 1





    The IDE plugin seems not to provide such functionality. I don't know which other "software" you may mean.

    – Michael Butscher
    Nov 24 '18 at 22:03





















  • Post the stack trace, it'll probably tell you what can't be cast

    – Speed
    Nov 24 '18 at 20:30






  • 4





    You can't just cast a JSONObject to whatever you want. You have to manually populate a new instance of your data class with the values in the JSONObject.

    – TheWanderer
    Nov 24 '18 at 20:32











  • Stacktrace added.

    – HWK
    Nov 24 '18 at 20:36






  • 1





    As @TheWanderer already stated, the compiler has no idea how to convert from JSONObject to replayDataObject. You must by hand create a conversion function (preferably an additional constructor for replayDataObject) which takes the wanted data out of the JSONObject and calls replayDataObject's primary constructor to place the data in its fields.

    – Michael Butscher
    Nov 24 '18 at 21:34






  • 1





    The IDE plugin seems not to provide such functionality. I don't know which other "software" you may mean.

    – Michael Butscher
    Nov 24 '18 at 22:03



















Post the stack trace, it'll probably tell you what can't be cast

– Speed
Nov 24 '18 at 20:30





Post the stack trace, it'll probably tell you what can't be cast

– Speed
Nov 24 '18 at 20:30




4




4





You can't just cast a JSONObject to whatever you want. You have to manually populate a new instance of your data class with the values in the JSONObject.

– TheWanderer
Nov 24 '18 at 20:32





You can't just cast a JSONObject to whatever you want. You have to manually populate a new instance of your data class with the values in the JSONObject.

– TheWanderer
Nov 24 '18 at 20:32













Stacktrace added.

– HWK
Nov 24 '18 at 20:36





Stacktrace added.

– HWK
Nov 24 '18 at 20:36




1




1





As @TheWanderer already stated, the compiler has no idea how to convert from JSONObject to replayDataObject. You must by hand create a conversion function (preferably an additional constructor for replayDataObject) which takes the wanted data out of the JSONObject and calls replayDataObject's primary constructor to place the data in its fields.

– Michael Butscher
Nov 24 '18 at 21:34





As @TheWanderer already stated, the compiler has no idea how to convert from JSONObject to replayDataObject. You must by hand create a conversion function (preferably an additional constructor for replayDataObject) which takes the wanted data out of the JSONObject and calls replayDataObject's primary constructor to place the data in its fields.

– Michael Butscher
Nov 24 '18 at 21:34




1




1





The IDE plugin seems not to provide such functionality. I don't know which other "software" you may mean.

– Michael Butscher
Nov 24 '18 at 22:03







The IDE plugin seems not to provide such functionality. I don't know which other "software" you may mean.

– Michael Butscher
Nov 24 '18 at 22:03














2 Answers
2






active

oldest

votes


















0














You need something that interprets the JSON to map it to the replayDataObject. In Kotlin, data classes are very good at this using any of a number of libraries.



Google Gson



https://github.com/google/gson



After initializing Gson, you would simply take that String:



gson.fromJson(jsonString, replayDataObject::class.java)


Now, a word of warning, you have a lot of non-nullable types in there, and there may be issues with the data you read in, or what you expect from it.



Other libraries:




  • https://github.com/cbeust/klaxon

  • https://github.com/square/moshi






share|improve this answer































    0














    Retrofit work for you.
    Get json from server and convert to object.



    https://square.github.io/retrofit/






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462077%2fandroid-kotlin-jsonobject-cannot-be-cast%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      You need something that interprets the JSON to map it to the replayDataObject. In Kotlin, data classes are very good at this using any of a number of libraries.



      Google Gson



      https://github.com/google/gson



      After initializing Gson, you would simply take that String:



      gson.fromJson(jsonString, replayDataObject::class.java)


      Now, a word of warning, you have a lot of non-nullable types in there, and there may be issues with the data you read in, or what you expect from it.



      Other libraries:




      • https://github.com/cbeust/klaxon

      • https://github.com/square/moshi






      share|improve this answer




























        0














        You need something that interprets the JSON to map it to the replayDataObject. In Kotlin, data classes are very good at this using any of a number of libraries.



        Google Gson



        https://github.com/google/gson



        After initializing Gson, you would simply take that String:



        gson.fromJson(jsonString, replayDataObject::class.java)


        Now, a word of warning, you have a lot of non-nullable types in there, and there may be issues with the data you read in, or what you expect from it.



        Other libraries:




        • https://github.com/cbeust/klaxon

        • https://github.com/square/moshi






        share|improve this answer


























          0












          0








          0







          You need something that interprets the JSON to map it to the replayDataObject. In Kotlin, data classes are very good at this using any of a number of libraries.



          Google Gson



          https://github.com/google/gson



          After initializing Gson, you would simply take that String:



          gson.fromJson(jsonString, replayDataObject::class.java)


          Now, a word of warning, you have a lot of non-nullable types in there, and there may be issues with the data you read in, or what you expect from it.



          Other libraries:




          • https://github.com/cbeust/klaxon

          • https://github.com/square/moshi






          share|improve this answer













          You need something that interprets the JSON to map it to the replayDataObject. In Kotlin, data classes are very good at this using any of a number of libraries.



          Google Gson



          https://github.com/google/gson



          After initializing Gson, you would simply take that String:



          gson.fromJson(jsonString, replayDataObject::class.java)


          Now, a word of warning, you have a lot of non-nullable types in there, and there may be issues with the data you read in, or what you expect from it.



          Other libraries:




          • https://github.com/cbeust/klaxon

          • https://github.com/square/moshi







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 23:12









          gtcompscientistgtcompscientist

          613516




          613516

























              0














              Retrofit work for you.
              Get json from server and convert to object.



              https://square.github.io/retrofit/






              share|improve this answer




























                0














                Retrofit work for you.
                Get json from server and convert to object.



                https://square.github.io/retrofit/






                share|improve this answer


























                  0












                  0








                  0







                  Retrofit work for you.
                  Get json from server and convert to object.



                  https://square.github.io/retrofit/






                  share|improve this answer













                  Retrofit work for you.
                  Get json from server and convert to object.



                  https://square.github.io/retrofit/







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 27 '18 at 7:29









                  Vorawut ManawmooVorawut Manawmoo

                  11




                  11






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462077%2fandroid-kotlin-jsonobject-cannot-be-cast%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Wiesbaden

                      Marschland

                      Dieringhausen