0

I Have this JSON , needed it to post on the server , the problem how we send array of generic objects

  "items": [
            {
                "variant": {
                    "id": 48,
                    "quantity": "1"
                },
                "custom_form_data": {
                    "features": {
                        "delivery_email": "[email protected]",
                        "delivery_mobile": "+886970639636"
                    },
                    "customer_info": "TEST Han Customer Info"
                }
            }
        ],

this is the call

 items = arrayOf(
                        Variant(id = 48, quantity = "1"),
                        CustomFormData(features = Features("[email protected]", "+886970639636") ,customerInfo = "inof")
                    ),

1 Answer 1

1

Define a data class for that format, something like this:

data class Item (
   val variant: Variant,
   val custom_form_data: CustomFormData
)

And then in your retrofit ApiService interface definition:

interface ApiService {

   @POST('url')
   fun methodName(): List<Item>

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.