title: Create Json-string with Jackson using loops
body: <p>I have three <code>String[][]</code> arrays that can be of different lengths. The second length is always fixed, and has length of <code>6</code>, but the first length can differ between <code>0</code> and <code>6</code>. </p>
  
  <p>I want to create a Json-string containing the data of all of these <code>String</code> arrays. As of now it's hard coded, but i realize I'll get in to trouble once the lengths isn't fixed anymore...</p>
  
  <pre><code>travelgl1.put("Duration", str1[0][0]);
  travelgl1.put("Walking time", str1[0][1]);
  travelgl1.put("Direction", str1[0][2]);
  travelgl1.put("Departure", str1[0][3]);
  travelgl1.put("Arrival", str1[0][4]);
  travelgl1.put("End station", str1[0][5]);
  </code></pre>
  
  <p>So basically I want a dynamic loop that loops through the <code>String</code> arrays and adds all the data in that array.</p>
  
  <p>Is there any easy way to do this? I want all three json objects (from the three <code>String</code> arrays) to be compiled in to one big json string in the end. </p>
  
  <p>I want the end result to look like this:</p>
  
  <blockquote>
    <p>[ { "String array 1" : [ { "Duration" : "33", "Walking time" : "8", "Direction" : "Åkeshov", "Departure" : "09:39", "Arrival" : "10:43", "End station" : "Sollentuna" }, { "Duration" : "37", "Walking time" : "8", "Direction" : "Alvik", "Departure" : "09:43", "Arrival" : "10:51", "End station" : "Sollentuna" }, { "Duration" : "34", "Walking time" : "8", "Direction" : "Alvik", "Departure" : "09:53", "Arrival" : "10:58", "End station" : "Sollentuna" }, { "Duration" : "36", "Walking time" : "8", "Direction" : "Åkeshov", "Departure" : "09:59", "Arrival" : "11:06", "End station" : "Sollentuna" }, { "Duration" : "33", "Walking time" : "8", "Direction" : "Åkeshov", "Departure" : "10:09", "Arrival" : "11:13" } ] }, 
    { "String array 2" : [ { "Duration" : "54", "Walking time" : "13", "Direction" : "Farsta strand", "Departure" : "09:43", "Arrival" : "11:13", "End station" : "Sollentuna" }, { "Duration" : "47", "Walking time" : "13", "Direction" : "Gullmarsplan", "Departure" : "09:50", "Arrival" : "11:13", "End station" : "Sollentuna" }, { "Duration" : "45", "Walking time" : "13", "Direction" : "Gullmarsplan", "Departure" : "10:00", "Arrival" : "11:21", "End station" : "Sollentuna" }, { "Duration" : "42", "Walking time" : "13", "Direction" : "Gullmarsplan", "Departure" : "10:10", "Arrival" : "11:28", "End station" : "Sollentuna" }, { "Duration" : "45", "Walking time" : "13", "Direction" : "Gullmarsplan", "Departure" : "09:30", "Arrival" : "10:51", "End station" : "Sollentuna" } ] }, 
    { "String array 3" : [ { "Duration" : "31", "Walking time" : "12", "Direction" : "Hässelby strand", "Departure" : "09:45", "Arrival" : "10:51", "End station" : "Sollentuna" }, { "Duration" : "31", "Walking time" : "12", "Direction" : "Alvik", "Departure" : "09:52", "Arrival" : "10:58", "End station" : "Sollentuna" }, { "Duration" : "33", "Walking time" : "12", "Direction" : "Åkeshov", "Departure" : "09:58", "Arrival" : "11:06", "End station" : "Sollentuna" }, { "Duration" : "30", "Walking time" : "12", "Direction" : "Åkeshov", "Departure" : "10:08", "Arrival" : "11:13", "End station" : "Sollentuna" }, { "Duration" : "31", "Walking time" : "12", "Direction" : "Hässelby strand", "Departure" : "10:15", "Arrival" : "11:21", "End station" : "Sollentuna" } ] } ]</p>
  </blockquote>
  
  <p>So, what I really want is a dynamic way of creating a Json string depending on the length of the string array. </p>
  
  <p>Thanks in advance! </p>