Guest User

Untitled

a guest
Feb 15th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public static void main(String myHelpers[]){
  2. String jsonString = "{\"infile\": [{\"field1\": 11,\"field2\": 12,\"field3\": 13},{\"field1\": 21,\"field2\": 22,\"field3\": 23},{\"field1\": 31,\"field2\": 32,\"field3\": 33}]}";
  3.  
  4. JSONObject output;
  5. try {
  6. output = new JSONObject(jsonString);
  7.  
  8.  
  9. JSONArray docs = output.getJSONArray("infile");
  10.  
  11. File file=new File("/tmp2/fromJSON.csv");
  12. String csv = CDL.toString(docs);
  13. FileUtils.writeStringToFile(file, csv);
  14. } catch (JSONException e) {
  15. e.printStackTrace();
  16. } catch (IOException e) {
  17. // TODO Auto-generated catch block
  18. e.printStackTrace();
  19. }
  20. }
Add Comment
Please, Sign In to add comment