I'm currently working on a project where I upload a file through their REST API and their server returns the following in JSON.
[{"code":0,"id":"19348139481","name":"file.bin"}]
with "code" having the possible 3 values:
- 0 upload successful
- 1 file too big
- 2 could not save file
I am able to get each pair of key/value after removing the brackets, but is there any way that I associate the "code" with its message? What I would like to do is to define the code like in C++
define 0 UPLOAD_SUCCESSFUL
define 1 FILE_TOO_BIG
define 2 COULDNT_SAVE_FILE
So that way when i get the "code" i can display the corresponding message like:
System.out.println(code.msg);