title: Python: array of points to JSON
body: <p>I am new to Python and I am trying since this morning to convert an object (which I believe it's an array of points) to JSON.</p>
  
  <pre><code>print "myobject type is: %s" % type(myobject)
  print "myobject[0] is %s" % myobject[0]
  myobjectJson = json.dumps(myobject)
  </code></pre>
  
  <p>result</p>
  
  <pre><code> myobject type is: class 'dlib.dlib.points'
  
   myobject[0] is (190, 254)
  
   Traceback (most recent call last):
    File "./face_landmark_detection.py", line 103, in &lt;module&gt;
      myobjectJson = json.dumps(myobject)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 243, in dumps
      return _default_encoder.encode(obj)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 207, in encode
      chunks = self.iterencode(o, _one_shot=True)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 270, in iterencode
      return _iterencode(o, 0)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default
      raise TypeError(repr(o) + " is not JSON serializable")
  TypeError: &lt;dlib.dlib.points object at 0x1086db650&gt; is not JSON serializable
  </code></pre>
  
  <p>so, as far as I can see this object is not JSON serializable.</p>
  
  <p>I have tried to use:</p>
  
  <pre><code>myobjectJson = json.dumps(myobject, default=list)
  myobjectJson = json.dumps(myobject, default=tuple)
  myobjectJson = json.dumps(myobject, default=dict)
  myobjectJson = json.dumps(myobject, default=__dict__)
  myobjectJson = json.dumps(myobject, default=lambda o: o.__dict__)
  </code></pre>
  
  <p>But I keep getting the same error...
  what can I do?</p>
  
  <p>Thank you</p>
  
  <p><strong>update</strong></p>
  
  <pre><code>dir myobject is: ['__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__getstate__', '__hash__', '__init__', '__instance_size__', '__iter__', '__len__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__safe_for_unpickling__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'append', 'clear', 'extend', 'resize']
  dir myobject[0] is: ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getstate__', '__hash__', '__init__', '__instance_size__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__safe_for_unpickling__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'x', 'y']
  </code></pre>