I am trying to pass a JSON string to my PHP script, but I am unsure of how to build the string in a way that considers there could be 0 or more telephones, emails and faxes.
Here is an example of what my string looks like:
{"mode": "ADD_CONTACT", "id": 316, "firstname": "", "lastname": "", "telephones": {"teltype": 1, "telnumber": "234523453245", "isprimary": 0, "teltype": 4, "telnumber": "657567567567", "isprimary": 0}}
The problem is that my script only gives me the last phone number, presumably because the JSON parameter names are the same, so what format should I use to achieve what I want? I would like to avoid sticking incremental numbers on the end of the parameter names i.e. “telnumber1”, “telnumber2” etc.
Use an array (which can be empty):
Example: