title: JSON Parser Error :Value null of type org.json.JSONObject$1 cannot be converted to JSONObject
body: <p>I am getting the following error:</p>
  
  <p><a href="https://i.stack.imgur.com/fyJxo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fyJxo.png" alt="enter image description here"></a></p>
  
  <p>This is my source code:</p>
  
  <pre><code>package com.example.arpok.iomatic;
  
  
  LineGraphSeries&lt;DataPoint&gt; series;
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; arrayListData;
  public static String data;
  TextView graphOneTV,graphTwoTV,graphThreeTV;
  GraphView graph;
  String x,y;
  public Graph_Fragment() {
  }
  
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      return inflater.inflate(R.layout.fragment_graph_, container, false);
  }
  HttpURLConnection connection;
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  
      graphOneTV = (TextView) getView().findViewById(R.id.TVGraph1);
      graphTwoTV = (TextView) getView().findViewById(R.id.TVGraph2);
      graphThreeTV = (TextView) getView().findViewById(R.id.TVGraph3);
      graph = (GraphView) getView().findViewById(R.id.graph1);
      graphDataClass gdc = new graphDataClass();
      gdc.execute();
  
  
  }
  public class graphDataClass extends AsyncTask&lt;String ,String ,String&gt;
  {
      @Override
      protected String doInBackground(String... strings) {
  
          try {
              URL url = new URL("http://192.168.1.34/getGraphData.php?");
              HttpURLConnection connection = (HttpURLConnection) url.openConnection();
              InputStream inputStream = connection.getInputStream();
              BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
              String line = "";
              while(line != null)
              {
                  line = bufferedReader.readLine();
                  data = data + line;
              }
  
              JSONObject jo = new JSONObject(data);
  
              for(int i=0;i&lt;data.length();i++) {
  
                  x = jo.getString("twitter");
                  y = jo.getString("googleplus");
  
                  System.out.print("x: "+x+"y: "+y);
  
                  HashMap&lt;String, String&gt; tempHashMapData = new HashMap&lt;&gt;();
  
                  tempHashMapData.put("twitter",x);
                  tempHashMapData.put("googleplus",y);
  
                  arrayListData.add(tempHashMapData);
              }
  
  
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          } catch (JSONException e) {
              e.printStackTrace();
          }
          return null;
      }
  
  
      protected void onPreExecute()
      {
          super.onPreExecute();
      }
      protected  void onPostExecute(String s  )
      {
          super.onPostExecute(s);
          graphOneTV.setText(data);
  
      }
  }}
  </code></pre>
  
  <p>The above code is the fragment in which I need to fetch the data form the JSON and plot it on the graph. The thing is when I am displaying the "data" named  variable which is having the JSON data on a textView then it is showing properly but when I am assigning the same "data" variable to the JSONObject then the above error occurs.</p>
  
  <p>This is my Json data which i need to plot on the Line Graph</p>
  
  <pre><code>[{"twitter":"200","googleplus":"60"},{"twitter":"150","googleplus":"180"},{"twitter":"90","googleplus":"120"}]
  </code></pre>
  
  <p>Someone please tell me how can I fetch the JSON data and parse it and plot it on a line graph.</p>