Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String myHelpers[]){
- String jsonString = "{\"infile\": [{\"field1\": 11,\"field2\": 12,\"field3\": 13},{\"field1\": 21,\"field2\": 22,\"field3\": 23},{\"field1\": 31,\"field2\": 32,\"field3\": 33}]}";
- JSONObject output;
- try {
- output = new JSONObject(jsonString);
- JSONArray docs = output.getJSONArray("infile");
- File file=new File("/tmp2/fromJSON.csv");
- String csv = CDL.toString(docs);
- FileUtils.writeStringToFile(file, csv);
- } catch (JSONException e) {
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment