title: how to generate a json object in kotlin?
body: <p>I'm really new in programming, and recently started a project in Kotlin with Android Studio. </p>
  
  <p>So, I have a problem with a JSON object. I get data from an BroadcastReceiver object, a String to be more specific, with the next format:</p>
  
  <pre><code>{"s1":1}
  </code></pre>
  
  <p>This, is a simple string. So I took in a function call toJson and I do this.</p>
  
  <pre><code>private fun toJson(data:String): JSONObject {
  
      var newData: String = data.replace("\"","")
      newData = newData.replace("{","")
      newData = newData.replace("}","")
  
      val newObject = newData.split(":")
      val name = newObject[0]
      val value = newObject[1]
      val rootObject = JSONObject()
      rootObject.put(name,value)
  
      return rootObject
  }
  </code></pre>
  
  <p>Im doing this the right way?, how can I improve my code?</p>
  
  <p>Thanks for your help, and sorry for my english!</p>