convert CSV to JSON with exhaustive fileds : I want to convert my JSON {\"field1\": 11,\"field3\": 13},{\"field1\": 21,\"field2\": 22,\"field3\": 23},{\"field1\": 31,\"field2\": 32,\"field3\": 33,\"field4\": 34}  to CSV Its returning
field3	field1
13	  11
23	 21
33	 31
It should rather return 
field1	field2	field3	field4
11		        13	
21	     22	    23	
31	     32	    33	     34

I am using below code

	      String jsonString1 = "{\"infile\": [{\"field1\": 11,\"field3\": 13},{\"field1\": 21,\"field2\": 22,\"field3\": 23},{\"field1\": 31,\"field2\": 32,\"field3\": 33,\"field4\": 34}]}";


      try {
			output = new JSONObject(jsonString1);
			 String destination = "tmp/json2csv.csv";
			 JSONArray docs = output.getJSONArray("infile");
			 
			 File file=new File(destination);
			 String csv = CDL.toString(docs);
			 FileUtils.writeStringToFile(file, csv);
		} catch (JSONException e) {

		}

