A secret about my Web API Response

aeric

Expert
Licensed User
Longtime User
Some of you may know I created a Web API template or framework and the API will return a standard format of JSON response.
For example:
URL: https://api.puterise.com:19900/v1/topic
The response looks like this:
JSON:
{
    "a": 200,
    "r": [
        {
            "topic": "B4X (default)"
        }
    ],
    "s": "ok",
    "e": null,
    "m": "Success"
}

What are those key initials mean?
You may guess:
s = Status (ok or error/failed)
e = Errors
m = Messages
r = Results/Response data/Database query rows
a = code?

Why “a” represents the Status code?
How I came with these initial codes?

The background is coming from a commercial public API I was working on during my previous job. If I am not mistaken, it is from GDex, a logistics service provider.

But some keys are not exists in that API. I added “a” in the JSON response later in my API. I would have used a letter “c” but I ended up using a letter “a”.

This come from the combination of these letters. If I rearrange the letters, I can produce a word “MESRA” which means “friendly” in Malays (my national language). But beware, if you may also rearrange the letters to another word, “SERAM” which mean “scary” in Malays. 😝
 
Last edited:

jahswant

Well-Known Member
Licensed User
Longtime User
This is how to parse the response.

B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim a As Int = root.Get("a")
Dim r As List = root.Get("r")
For Each colr As Map In r
 Dim topic As String = colr.Get("topic")
Next
Dim s As String = root.Get("s")
Dim e As String = root.Get("e")
Dim m As String = root.Get("m")
 

aeric

Expert
Licensed User
Longtime User
This is how to parse the response.

B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim a As Int = root.Get("a")
Dim r As List = root.Get("r")
For Each colr As Map In r
 Dim topic As String = colr.Get("topic")
Next
Dim s As String = root.Get("s")
Dim e As String = root.Get("e")
Dim m As String = root.Get("m")
This is not a question.
But I may raise a question.
The question is, “what word do you suggest for the initial A for representing the Status code?”
So far I can’t think of any.
 

aeric

Expert
Licensed User
Longtime User
This is not a question.
But I may raise a question.
The question is, “what word do you suggest for the initial A for representing the Status code?”
So far I can’t think of any.
Maybe :
A = Acknowledgement code
A = API status code
A = Aeric’s secret number
A = Anything but not scary
A = A 3-digit number
A = Ask Aeric
 
Top