0

I'm wondering if, is there any way I can pass an array like below to my Swift application without using JSON.

["Wifi", "Internet", "Telephone", "Network"]

If I'm using JSON, from what I understand, I need to transform the array to a dictionary to get it to my Swift application. My objective is to get the array as it is and use it in my code, so the fact that we need to use JSON here is a little bit redundant or not so convenient.

Zaki Zakaria
  • 127
  • 1
  • 17
  • 1
    _If I'm using JSON, from what I understand, I need to transform the array to a dictionary to get it to my Swift application._ **-** Is that because of Swift? Because it is not necessary for PHP. – Philipp Maurer Nov 30 '17 at 10:52
  • 2
    No, that statement is completely incorrect. Just json_encode it on the php side and parse it on the swift side, simple as that, nothing special. – luk2302 Nov 30 '17 at 10:54
  • Yeah, I think it's because of Swift...you can check it out here https://stackoverflow.com/questions/27750663/how-can-i-get-a-php-variable-over-to-swift @PhilippMaurer – Zaki Zakaria Nov 30 '17 at 10:54
  • I think it is because that person used an associatve array. Since you do not use one, it might work. @luk2302 seemts to understand the Swift part and seems to agree that it is not necessary. – Philipp Maurer Nov 30 '17 at 10:57
  • Array in PHP <=> Array in Swift # Associative Array in PHP <=> Dictionary in Swift. – luk2302 Nov 30 '17 at 10:59
  • JSON is pretty standardised so you should not have problems, especially if both languages communicate via some HTTP-API. The overhad of encoding/decoding JSON should be negligable as well. Nevertheless I remember there was some library that allowed for something like RPC calls between different programming languages and one only had to help it map certain datastructures, but I can't remember the name. – dbrumann Nov 30 '17 at 11:02

0 Answers0