title: Why is Jansson's is_json_object() failing to recognize my JSON string?
body: <p>I am new to C++ and cannot figure out how to strip some miscellaneous data from a string and then parse it as JSON.</p>
  
  <p>I've ended up using the most documented JSON parser I could find - jansson. It seems excellent, although I'm stuck at the first hurdle.</p>
  
  <p>My program receives a string in the following format:</p>
  
  <pre><code>5::/chat:{"name":"steve","args":[{"connection":"true"}, { "chatbody" : "I am the body" }]}
  </code></pre>
  
  <p>I've stripped everything outside the curly brackets with:</p>
  
  <pre><code>std::string str=message;
  unsigned pos = str.find("{");
  std::string string = str.substr (pos);
  </code></pre>
  
  <p>That leaves:</p>
  
  <pre><code>{
      "name": "steve",
      "args": [
          {
              "connection": "true"
          },
          {
              "chatbody": "I am the body"
          }
      ]
  }
  </code></pre>
  
  <p>I'm stuck at stage one parsing this. I have converted the string to a char and then tried to use json_loads, but I don't get anything useful out...</p>
  
  <p>The whole thing looks like this:</p>
  
  <pre><code>void processJson(string message)
  {
      json_t *root;
      json_error_t error;
      size_t i;
  
      std::string str=message;
      unsigned pos = str.find("{");
      std::string str3 = str.substr (pos);
  
      const char * c = str.c_str();
  
      json_t *data, *sha, *name;
  
      root = json_loads(c, 0, &amp;error);
      data = json_array_get(root, i);        
      cout &lt;&lt; data;
  
      if(!json_is_object(root))
      {
        fprintf(stderr, "error: commit data %d is not an object\n", i + 1);
      }
  
  }
  </code></pre>
  
  <p>I need to get the values out, but I just get 01, 02, 03....</p>
  
  <p>is_json_object just says:</p>
  
  <pre><code>error: commit data 1068826 is not an object
  error: commit data 1068825 is not an object
  error: commit data 1068822 is not an object
  </code></pre>
  
  <p>What am I doing wrong and how can I properly format this? Ultimately I'll need to iterate over an array but cannot get past this. I'm sure this is just a beginner's mistake.</p>
  
  <p>-EDIT- </p>
  
  <p>Trying to avoid using Boost because of a strict size requirement.</p>