0

i am trying to declare produits in the request this request contains the name, address ... and the product inside of it there are many objects as shown her

produits: Array(3) 0: {idProduits: "60823e87db0f3a2c4cfedaed", nameprduits: "mini Airbus A330", prixprduits: 16.5, quantitep: 2, total: undefined, …} 1: {idProduits: "60823e87db0f3a2c4cfedaec", nameprduits: "VELOCIRAPTOR", prixprduits: 50, quantitep: 2, total: undefined, …} 2: {idProduits: "60823e87db0f3a2c4cfedaeb", nameprduits: "mini VELOCIRAPTOR", prixprduits: 18, quantitep: 2, total: undefined, …}

i triyed List<List> , List ,List , Object ...

my request : facture adresse: "tunis / benarous" livraison: 7 nom: "medbaha1" produits: Array(3) 0: {idProduits: "60823e87db0f3a2c4cfedaed", nameprduits: "mini Airbus A330", prixprduits: 16.5, quantitep: 2, total: undefined, …} 1: {idProduits: "60823e87db0f3a2c4cfedaec", nameprduits: "VELOCIRAPTOR", prixprduits: 50, quantitep: 2, total: undefined, …} 2: {idProduits: "60823e87db0f3a2c4cfedaeb", nameprduits: "mini VELOCIRAPTOR", prixprduits: 18, quantitep: 2, total: undefined, …} length: 3 proto: Array(0) siege: "marsa" tel: "50140787" total: 176 totalht: 142.01680672268907 totaltva: 26.98319327731093 proto: Object

and thanks

med baha
  • 80
  • 7
  • I am sorry. Not clear with your question to answer – Tamil.S May 13 '21 at 04:35
  • I am sending a requests that contain facture body like the name and number total cost and it it contains a list of products I don't know how to declare this entity. This is the body of products produits: idProduits: "60823e87db0f3a2c4cfedaed", nameprduits: "mini Airbus A330", prixprduits: 16.5, quantitep: 2, total: undefined, …} 1: {idProduits: "60823e87db0f3a2c4cfedaec", nameprduits: "VELOCIRAPTOR", prixprduits: 50, quantitep: 2, total: undefined, …} 2: {idProduits: "60823e87db0f3a2c4cfedaeb", nameprduits: "mini VELOCIRAPTOR", prixprduits: 18, quantitep: 2, total: undefined, …} – med baha May 13 '21 at 09:47

1 Answers1

1

Below is my understanding.

name: 'aaa'
totalCost: 500
produits[
    0 {idProduits: "60823e87db0f3a2c4cfedaed", nameprduits: "mini Airbus A330", prixprduits: 16.5, quantitep: 2, total: undefined, …} 
    1: {idProduits: "60823e87db0f3a2c4cfedaec", nameprduits: "VELOCIRAPTOR", prixprduits: 50, quantitep: 2, total: undefined, …} 
    2: {idProduits: "60823e87db0f3a2c4cfedaeb", nameprduits: "mini VELOCIRAPTOR", prixprduits: 18, quantitep: 2, total: undefined, …}
]

If the above one is your request means , you may need a two entity with fields something like below, Entity.class

Private String name;
Private long totalCost;
private List<Produits> produitsList;

Produits.class

private String idProduits:
private String nameprduits;
private Long/Float prixprduits;
private int quantitep;
private int total;
Tamil.S
  • 403
  • 3
  • 14
  • Every thing get results of null – med baha May 14 '21 at 13:14
  • Can you post your entity file ? – Tamil.S May 14 '21 at 13:29
  • Document(collection = "facture") public class facture { @Id private String idFacture; private String nom; private String adresse; private String tel; private String siege; private List produits; private int totaltva; private int totalht; private int total; private int livraison; public void setStatu(boolean statu) { this.statu = statu; } public boolean isStatu() { return statu; } private boolean statu=false; – med baha May 14 '21 at 23:16
  • public class Produitsdefacture { @Id private String idproduitsfacture; private String nameprduits; private Float prixprduitsHT; private Float prixprduitsTVA; private Float prixprduits; private int quantitep; private int totalproduit; – med baha May 14 '21 at 23:17
  • 1
    Below are the possible reasons you getting null values. 1. Create Getter and Setter using lambok / corresponding setter getter methods for your fields. 2. And also make sure , first char of fields are lowercase. https://stackoverflow.com/a/38939812/7485135 3. Check the field name in entity matches with your request fields that may comes from front end side. If not, you can bind variables with @JSONProperty – Tamil.S May 15 '21 at 06:24