Hello guys,
I did it! I started Android dev and it is a lot of fun. For my first app, I am trying to upload an image to a server which return a JSON string/object in this form:
serverResponse = {"category_outputs": [0.099017499999999994, 0.096076599999999998, 0.098027299999999998, 0.097047099999999997, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "imageid": "2009-07-23-17.22.32.287593.png"}
I am only interested in the float/numbers and would like to convert this server return string into a float array that looks like:
array = [0.099017499999999994, 0.096076599999999998, 0.098027299999999998, 0.097047099999999997, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
My understanding is that Android has it own JSON parsing method but I am not sure how to use them. I see something like:
org.json, JSONArray, JSONObject..and so on but I have no clue how to actually use them. I have looked at the Google info but they do not have an example on how to use that parser other than explaining the object themselves.
I am basically stuck with my little project of uploading an image to a server. The uploading and return works great but I need to figure out the parsing part.
Thanks for any pointers.
Mo.
ps: By the way, plusminus you did a heck of job with this site! I have learned so much looking at your tutorials it is amazing. This seems to be a vibrant community and I am extremely I joined. THANKS!





