Can Not Parse Json Response using Retrofit and Moshi

indent preformatted text by 4 spaces


  • The [ViewModel] that is attached to the [NewsHomeFragment].
    class NewsViewModel : ViewModel() {

    // The internal MutableLiveData String that stores the most recent response
    private val _response = MutableLiveData()

    // The external immutable LiveData for the response String
    val response: LiveData
    get() = _response


    • Call getMarsRealEstateProperties() on init so we can display status immediately.
      init {


    • Sets the value of the status LiveData to the Mars API status.
      private fun getMarsRealEstateProperties() {
      _response.value = NewsApi.retrofitService.getProperties().enqueue(
      object: Callback {
      override fun onFailure(call: Call, t: Throwable) {
      _response.value = "Failure: " + t.message

           override fun onResponse(call: Call<NewsData>, response: Response<NewsData>) {
               _response.value = response.body().toString()


private val moshi = Moshi.Builder()

private val retrofit = Retrofit.Builder()

interface NewsApiService {
fun getProperties():

object NewsApi {
val retrofitService : NewsApiService by lazy {
retrofit.create( }

//Json response from the webservice

//image of how the data appears on my device

eh, select your code and press indent will work
placing the instruction of how to make something look like code above the code is a bit odd :wink: