title: Problem of Json parse when i send an body object from Flutter to node.js while it works perfect with postman
body: <p>i have a function in node.js and MySQL that works very fine , i have an object json of a club that contains a list of players.
  So i created a function of node.js that takes this object and insert it
  I did a test with postman and everything working perfect!</p>
  <p>here the json object that works perfect in postman:</p>
  <pre><code> {
       &quot;userid&quot;: 41,
      &quot;name&quot;: &quot;fc dhya club&quot;,
      &quot;price&quot;: 11,
      &quot;players&quot;: [
          {
              &quot;id&quot;:1,
              &quot;firstname&quot;:&quot;aaaaaaa&quot;,
              &quot;lastname&quot;:&quot;ee&quot;,
              &quot;position&quot;:&quot;df&quot;,
              &quot;price&quot;:12.1,
              &quot;appearences&quot;:2,
              &quot;goals&quot;:1,
              &quot;assists&quot;:1,
              &quot;cleansheets&quot;:1,
              &quot;redcards&quot;:1,
              &quot;yellowcards&quot;:1,
              &quot;image&quot;:&quot;qq&quot;
          },
    {
              &quot;id&quot;:2,
              &quot;firstname&quot;:&quot;aabbbbbbbbbbb&quot;,
              &quot;lastname&quot;:&quot;ee&quot;,
              &quot;position&quot;:&quot;df&quot;,
              &quot;price&quot;:12.1,
              &quot;appearences&quot;:2,
              &quot;goals&quot;:1,
              &quot;assists&quot;:1,
              &quot;cleansheets&quot;:1,
              &quot;redcards&quot;:1,
              &quot;yellowcards&quot;:1,
              &quot;image&quot;:&quot;qq&quot;
          }
      ]
       }
  </code></pre>
  <p>Here a screen capture that shows that it works perfect in Postman:
  <a href="https://i.stack.imgur.com/ATaqs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ATaqs.png" alt="enter image description here" /></a></p>
  <p>and it works perfect when i send the request</p>
  <p>but my problem is in flutter is that i wanted to send this structure of json to node.js so i created a model in dart that is called CLubJson:</p>
  <pre><code>// To parse this JSON data, do
  //
  //     final clubJson = clubJsonFromJson(jsonString);
  
  import 'dart:convert';
  
  ClubJson clubJsonFromJson(String str) =&gt; ClubJson.fromJson(json.decode(str));
  
  String clubJsonToJson(ClubJson data) =&gt; json.encode(data.toJson());
  
  class ClubJson {
    ClubJson({
      this.userid,
      this.name,
      this.price,
      this.players,
    });
  
    int userid;
    String name;
    double price;
    List&lt;Player&gt; players;
  
    factory ClubJson.fromJson(Map&lt;String, dynamic&gt; json) =&gt; ClubJson(
      userid: json[&quot;userid&quot;],
      name: json[&quot;name&quot;],
      price: json[&quot;price&quot;],
      players: List&lt;Player&gt;.from(json[&quot;players&quot;].map((x) =&gt; Player.fromJson(x))),
    );
  
    Map&lt;String, dynamic&gt; toJson() =&gt; {
      &quot;userid&quot;: userid,
      &quot;name&quot;: name,
      &quot;price&quot;: price,
      &quot;players&quot;: List&lt;dynamic&gt;.from(players.map((x) =&gt; x.toJson())),
    };
  }
  
  class Player {
    Player({
      this.id,
      this.firstname,
      this.lastname,
      this.position,
      this.price,
      this.appearences,
      this.goals,
      this.assists,
      this.cleansheets,
      this.redcards,
      this.yellowcards,
      this.image,
    });
  
    int id;
    String firstname;
    String lastname;
    String position;
    double price;
    int appearences;
    int goals;
    int assists;
    int cleansheets;
    int redcards;
    int yellowcards;
    String image;
  
    factory Player.fromJson(Map&lt;String, dynamic&gt; json) =&gt; Player(
      id: json[&quot;id&quot;],
      firstname: json[&quot;firstname&quot;],
      lastname: json[&quot;lastname&quot;],
      position: json[&quot;position&quot;],
      price: json[&quot;price&quot;].toDouble(),
      appearences: json[&quot;appearences&quot;],
      goals: json[&quot;goals&quot;],
      assists: json[&quot;assists&quot;],
      cleansheets: json[&quot;cleansheets&quot;],
      redcards: json[&quot;redcards&quot;],
      yellowcards: json[&quot;yellowcards&quot;],
      image: json[&quot;image&quot;]
    );
  
    Map&lt;String, dynamic&gt; toJson() =&gt; {
      &quot;id&quot;: id,
      &quot;firstname&quot;: firstname,
      &quot;lastname&quot;: lastname,
      &quot;position&quot;: position,
      &quot;price&quot;: price,
      &quot;appearences&quot;: appearences,
      &quot;goals&quot;: goals,
      &quot;assists&quot;: assists,
      &quot;cleansheets&quot;: cleansheets,
      &quot;redcards&quot;: redcards,
      &quot;yellowcards&quot;: yellowcards,
      &quot;image&quot;: image
    };
  }
  </code></pre>
  <p>and then i created a post method for this object</p>
  <pre><code>PostRequest() async {
  // set up POST request arguments
      final url = Uri.parse('http://192.168.1.16:3000/api/questions/addQuestion');
      Map&lt;String, String&gt; headers = {&quot;Content-type&quot;: &quot;application/json&quot;};
      ClubJson club = ClubJson(userid: 1, name: &quot;dsds&quot;, price: 55.2,players: [Player(id:1,firstname:&quot;d&quot;,lastname:&quot;ds&quot;,position:&quot;ez&quot;,price: 5.2,appearences:1,goals:1,assists:1,cleansheets:1,yellowcards:1,redcards:2,image:&quot;dsd&quot;)] );
      // for(var item in widget.selectedPlayers){
      //   club.players.add(Player(id:item.playerID,firstname:item.firstName,lastname:item.lastName,position:item.position,price:item.price,appearences:item.appearances,goals:item.goals,assists:item.assists,cleansheets:item.cleanSheets,redcards:item.redCards,yellowcards:item.yellowCards,image:item.image));
      // }
  
      String json = club.toJson().toString();
      print(club.name);
      print(club.price);
      for(var item in club.players){
        print(item.price);
      }
  
      // make POST request
      Response response = await post(url, headers: headers, body: json);
      // check the status code for the result
      int statusCode = response.statusCode;
      // this API passes back the id of the new item added to the body
      String body = response.body;
  
      // var res = jsonDecode(response.body);
      // if(res == &quot;success&quot;){
      //
      //   Navigator.push(context, MaterialPageRoute(builder: (context)=&gt;BottomNavBarV2(),),);
     return response;
    }
  </code></pre>
  <p><em><strong>Tip:</strong></em>  My goals is that this function will generate an identical json to the json that i used by postman on the top</p>
  <p><em><strong>After execution</strong></em> I have got an error of Json Parse in node.js which means that the Json i sent by Flutter is different or mal formed and node.js could not parse it</p>
  <p><em><strong>My Goal</strong></em> is to make my body object identical to the Json of Posman that works perfect</p>
  <p>Here a screen capture after the execution in Flutter</p>
  <p><a href="https://i.stack.imgur.com/kooXL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kooXL.png" alt="enter image description here" /></a></p>