1

I hit on a link that return me records in JSON array format from android mobile. If records count is zero(0) or user have no records, Then what should I prefer : 1. 404 error code. 2. Blank JSON array.

Is there any standard, then give me a link for that standard.

Akashsingla19
  • 690
  • 2
  • 8
  • 18

1 Answers1

4

It is not an error. user exists. go for Blank JSON array. display the error when there is no such user.

The JSON format standard doesn't include a criteria for your question. It's only for validating the format.

There is a case were you want to send the error message instead of the empty array. thats you want to show the user a message and this message is handled by the server.

hasan
  • 23,815
  • 10
  • 63
  • 101
  • I want to know that there is any standard for this situation or standard way to handle this situation. Which is better 404 or blank JSON array? – Akashsingla19 Oct 01 '15 at 07:00
  • There is no such standard. It the logical thing to do based on your situation. I gave you an example for both. – hasan Oct 01 '15 at 07:02