Q:

How to create json using textviews? android studio

i want to create a json like this:
{
"blogs":{  
   "blog":{
      "id":"","name":"","date":"","cant_post":0
       },
        "detailblog":[{
          "id":"","name":"","date":0,"cant_post":0,
          "creator":0,"theme":0
        },
        {
          "id":"","name":"","date":0,"cant_post":0,
          "creator":0,"theme":0
        },
        {
          "id":"","name":"","date":0,"cant_post":0,
          "creator":0,"theme":0
        }]
   }
}

from my textviews 
name = txtName.getText().toString;
id = txtId.getText().toString;

etc
but i do not know how, neither know how the {} [] are added to json 
can someone explain me or tell me an how to create it? thanks

A:

Let's solve via a bottom up approach
1.create detailblog array
JSONObject detailblog1 = new JSONObject();

    try {
        detailblog1.put("id","");
        detailblog1.put("name","");
        detailblog1.put("date",0);
        detailblog1.put("cant_post",0);
        detailblog1.put("creator",0);
        detailblog1.put("theme",0);

    } catch (JSONException e) {
        e.printStackTrace();
    }

    JSONObject detailblog2 = new JSONObject();

    try {
        detailblog2.put("id","");
        detailblog2.put("name","");
        detailblog2.put("date",0);
        detailblog2.put("cant_post",0);
        detailblog2.put("creator",0);
        detailblog2.put("theme",0);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    JSONObject detailblog3 = new JSONObject();

    try {
        detailblog3.put("id","");
        detailblog3.put("name","");
        detailblog3.put("date",0);
        detailblog3.put("cant_post",0);
        detailblog3.put("creator",0);
        detailblog3.put("theme",0);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    JSONArray jsonArray = new JSONArray();

    jsonArray.put(detailblog1);
    jsonArray.put(detailblog2);
    jsonArray.put(detailblog3);

2.complete the blog JSONObject
JSONObject blogs= new JSONObject();

    try {

        blogs.put("blog",blog);
        blogs.put("detailblog",jsonArray);

    } catch (JSONException e) {
        e.printStackTrace();
    }

3.complete the blogs JSONObject
JSONObject json = new JSONObject();
    try {
        json.put("blogs",blogs);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    Log.d("json",json.toString());

