0

I need to expose an Array[][] to many different clients (iPhone, Android, PC, Unix, etc), and need to make it available over HTTP/s

This brings me to JSON, and makes me wonder how do all the other *endian machines work with JSON and will I need to worry about how the array will be reconstructed on other platforms.

Initially this will be an array of UTF8 strings, but I want to support other types, for example, Array[0][] will be a image, while Array[1][] will be a audio file. ...etc.

If JSON is the right way to send Array[][] data across HTTP, what "gotchas" should I be concerned about?

4
  • Are you really sending an array of arrays down the pipe, or just a simple array? (External access to an internal array of arrays feels like a code smell to me.) – DougM Dec 2 '13 at 4:38
  • @DougM I'm doing crypto work on X objects (int, string, image, anything) and they need to match byte-for-byte on both the client and server. Just because it's an array doesn't mean it's internal in my case, it's just the C++ data to be encrypted or validated. Of course there will be checks pre encryption/decryption – halfbit Dec 2 '13 at 4:54
  • Are you sending struts that need to be examined together, or an encryption package and some meta-data? If the former, I wouldn't send an array of arrays, I'd recommend a more literal serialization as application/octet-stream in a MIME message. And if the latter, a JSON object may be more appropriate. – DougM Dec 2 '13 at 5:08
  • The code smell reference is not to access to an array, but rather to a multidimentional array-of-arrays over HTTP. 'data[0][0] = "foo"' vs 'data[0]="foo"' – DougM Dec 2 '13 at 5:09
2

JSON is a way to serialize a data object to a text file. Aside from some XMP-related goodies, you don't get a lot of oomph over a classic mutipart MIME message for sending anything that isn't a collection of simple scalar values as JSON.

Of course, your UTF8 strings are "simple scalar values", and so fit in rather well with JSON. Yay!.

When you want to migrate to images and audio files, you may want to change to sending standard URL's, possibly as paths relative to the web service's URL. So, if you were the https://api.sample.org/MakerOfThings/ service, your JSON might look like:

{ 
  [ 
    ["awesome stuff", "image/cat01.png", "audio/meow.ogg"], 
    ["creepy stuff", "image/eww01.jpg", "image/eww02.jpg"] 
  ]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.