title: Storing an array of JSON Objects in a couchDB field value
body: <p>I'm trying to store an array of JSON objects like this as a single field value in a couchdb document (I have reformatted this field value with JSONLint for readability)</p>
  
  <pre><code>[
     {
         "identifier": "2208879208",
         "name": "Some name",
         "description": [
             "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
         ],
         "attractions": [
             {
                 "identifier": "1910",
                 "summaryTitle": "Some title"
             },
             {
                 "identifier": "1270",
                 "summaryTitle": "Another title"
             }
         ]
     },
     {
         "identifier": "2208879208",
         "name": "Some name",
         "description": [
             "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
         ],
         "attractions": [
             {
                 "identifier": "1910",
                 "summaryTitle": "Some title"
             },
             {
                 "identifier": "1270",
                 "summaryTitle": "Another title"
             }
         ]
  }
  </code></pre>
  
  <p>]</p>
  
  <p>The original data is from a Solr query, which I then send to couchDB with Mickael Bailly's CodeIgniter couchdb library, on PHP 5.3, and apache 2.2.22, couchDB 1.3.0 on Windows 8  WAMPserver</p>
  
  <p>It's valid JSON according to JSONLint, and I can create the document fine, but when I view the document in Futon, couchdb seems to have treated it like a string rather than an array of objects, and I'm unable to click the + signs in Futon to expand / contract the nodes within the saved field UNTIL I double click the field value to edit the source, and add a space between the first 2 chars [ { and then click the tick again. </p>
  
  <p>It then displays in a clickable tree view, and I can read the doc field out again as JSON.</p>
  
  <p>So I guess my question is - What am I missing when I create my couch document? Do I need to format the field data differently? </p>
  
  <p>CouchDB seems to treat this field just as a string value when I create the document, which I find odd. I've tried adding the space in manually before I send the data to couch but I get the same result.</p>
  
  <p>I've also tried using cURL manually to create the document (outside of the couchdb library) but I get exactly the same result and I'm stumped. Any tricks or tips would be much appreciated! I can't find anyone with a similar issue so I'm thinking I must have a basic misunderstanding here :s</p>
  
  <pre><code>$payload = json_encode($data_a);
  
  curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:5984/dbname/'.$uid);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); 
  curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json','Accept: */*'));
  curl_setopt($ch, CURLOPT_USERPWD, 'user:pass');
  
  $response = curl_exec($ch);
  curl_close($ch);
  </code></pre>