title: Dart Convert List as Map Entry for JSON Encoding
body: <p>I asked a <a href="https://stackoverflow.com/questions/25615241/dart-json-decoder">question</a> before about Dart encoding/decoding to JSON, however, the libraries that were suggested were not complete and I decided to manually handle that.</p>
  
  <p>The objective is to convert these objects to a map. </p>
  
  
  
  <pre class="lang-dart prettyprint-override"><code>class Parent extends Object {
     int id;
     String name;
     List&lt;Child&gt; listChild = new List&lt;Child&gt;();
     Map toMap() =&gt; {"id":id, "name":name, "listChild":listChild};
  }
  
  class Child extends Object {
     int id;
     String childName;
     Map toMap() =&gt; {"id":id, "childName":childName};   
  }
  </code></pre>
  
  <p>When doing </p>
  
  <pre class="lang-dart prettyprint-override"><code>print(JSON.encode(parent.toMap()));
  </code></pre>
  
  <p>I am seeing it go here, any suggestion how to make this work?</p>
  
  <pre class="lang-dart prettyprint-override"><code>if (!stringifyJsonValue(object)) {
    checkCycle(object);
    try {
      var customJson = _toEncodable(object);
      if (!stringifyJsonValue(customJson)) {
        throw new JsonUnsupportedObjectError(object);
      }
      _removeSeen(object);
    } catch (e) {
      throw new JsonUnsupportedObjectError(object, cause : e);
    }
  }
  }
  </code></pre>