title: StringTokenizer, JSON and comma's
body: <p>I have a problem reading in strings with comma's within a JSON object within my Android project. A working JSON string is below:</p>
  
  <pre><code>{"success": "[TG2301_Stoke Holy Cross, TF7439_Thornham Corner, TL8583_Thetford]"}
  </code></pre>
  
  <p>But sometimes the place names have comma's, and that throws a wobbly with the JSON and StringTokenizer methods that I use to parse the JSON into key:values pairs, as shown below in last entry:</p>
  
  <pre><code>{"success": "[TG2301_Stoke Holy Cross, TF7439_Thornham Corner, TL8583_Thetford, North]"}
  </code></pre>
  
  <p>Before I found this bug I was using the following to parse the JSON:</p>
  
  <pre><code>StringTokenizer str1 = new StringTokenizer(str,"[,]");
  while (str1.hasMoreTokens()) {
  String val = str1.nextToken().trim();
  // Split the string at the underscore and do some stuff
  }
  </code></pre>
  
  <p>Can anyone suggest how to properly escape the comma within the placename string, either in the Java when creating the JSON, or within the StringTokenizer? Thanks.</p>