omniti-labs / jsend Goto Github PK
View Code? Open in Web Editor NEWJSend is a specification for a simple, no-frills, JSON based format for application-level communication.
License: BSD 3-Clause "New" or "Revised" License
JSend is a specification for a simple, no-frills, JSON based format for application-level communication.
License: BSD 3-Clause "New" or "Revised" License
I love this, and will use it 'til retirement. I would like to propose a little mod to play better with typing. I would like to replace data with sData and fData, such that I can strongly type the payloads, both sending and receiving.
JSend is a great standard.
Can I use the icon of JSend in any package in any language?
The website of JSend seems to be closed.
I can't find the icon anymore...
We are finding it difficult to agree on the correct jsend status for an HTTP 404 response. Could the spec clarify this somewhat special case?
Two schools of thought here.
fail
, with data
set to something like {"message": "Route not found"}
.I've taken a look at some implementations, and there seems to be some consensus for HTTP 404 being error
. However, my reading of the spec is that it should be fail
.
One thing that is not immediately clear from the specification is whether the 'data' key of the response should always be either a JSON object or a null, or whether it can be any valid JSON value. Indeed, the examples only show these two options, but other possibilities are not explicitly ruled out.
An example of a different format:
{
"status": "success",
"data": "Some string value"
}
If an endpoint specifically returns a single value of a primitive type, I am wondering if packaging that in an additional JSON object would be a bit superfluous?
I think that message
attribute could also be a part of fail
just as it is with error
.
As you describe it, FAIL is:
There was a problem with the data submitted, or some pre-condition of the API call wasn't satisfied
So in case of the former, the "problem with the data submitted" current structure makes perfect sense.
However for "some pre-condition of the API call wasn't satisfied" it does not quite work, and a "message" describing the problem seems to be much more logical. Because this pre-condition may not depend on what data user submitted, but on other conditions outside of it. For example maybe this request only works on certain days of the week?
It also allows to handle both fail
and error
responses in the same way, by showing an error or warning and message
response from the server.
For example, I have this fail response, but the frontend is a multilanguage app.
{
"status" : "fail",
"data" : { "username" : "Username already exists" }
}
Should I specify the language on a header and handle it on the backend? I thought that maybe could be a good idea to add a code in a nested object like this
{
"status" : "fail",
"data" : {
"username" : {
"message": "Username already exists",
"code": "usernameExists"
}
}
}
And the frontend should have a dictionary with "userAlreadyExists" to manage multilanguage error messages.
Thankyou for this helpful spec. I would like to request an addition to the spec - an optional key "log" which would be a list of log data generated during any given transaction.
For example:
{
status : "success",
data : {
"posts" : [
{ "id" : 1, "title" : "A blog post", "body" : "Some useful content" }
]
},
log: [
"New post created",
"Editor notified"
]
}
I don't think it is needed to specify what the type of itmes in the log key are. For example they could be dictionaries.
{
status : "success",
log: [
{"level": "DEBUG", "message": "Workflow state changed to published"}
]
}
Motivation: Particularly in admin interfaces it is helpful to have more detail on actions taken. For example an application could detect that a user is a system admin and generate more information in the return objects.
There may be cases where there may be multiple errors such as validation errors. In such cases, should the 'message' only consider the first error?
https://www.quora.com/What-are-the-things-which-are-banned-in-other-countries-except-in-India
Media will never inform you??
Nestle company accepts that they add juice extracted from Beef in chocolate Kitkat.
Media never informed you ???
That in a case in Chennai high court Fair & Lovely company accepted that the cream contains the oil from Pig fats !!
media never informed us that Vicks is banned in how many countries of Europe ! There it has been declared as slow poison ! But in our country we see it's advertising on TV whole day !!
media never informed us that Life bouy is neither bath soap nor toilet soap ! But it's
a Cabolic soap used for bathing animals !
Europe uses Life bouy for Dogs ! And in our country millions of humans use it !!
media never informed us ! ???????????
That Coke, Pepsi is in reality toilet cleaner ! it has been proved that it contains 21 types of different poisons ! And it's sale is banned in the canteen of indian parliament ! But it is sold in whole country !!
media never informed us ????
That foreign companies selling health tonics like Boost
Complan
Horlics
Maltova
Protin-ex., were tested in Delhi at All India Institute (which houses biggest laboratory in india) and it was found that it is made from the waste left after oil is extracted from Groundnut ! Which is food for animals ! From this waste they make health tonic !!
media never informed us ??????
When Amitabh Bachhan was operated in hospital for 10 long hours !
Doctor had to cut and remove large intestine !! and doctor had told him that it has rotten due to drinking of soft drinks like Coke, Pepsi ! And then he stopped advertising coke
pepsi !
Media is faithful to the advertisers.
Lots of people enjoy Pizzas today.
Let's have a look over pizza companies
"Pizza Hut
Dominos
KFC
McDonalds
Pizza Corner
Papa John’s Pizza
California Pizza Kitchen
Sal’s Pizza"
These are all american companies,
Note:- to make Pizza tasty...
E-631 flavor Enhancer is added which is made from Pork or Pig meat.
● Attention friends if following codes are mentioned on food packs then you should know what you are unknowingly consuming.
E 322 - Beef
E 422 - Alcohol
E 442 - Alcohol & Chemical
E 471 - Beef & Alcohol
E 476 - Alcohol
E 481 - mixture of Beef and Pork
E 627 - Dangerous Chemical
E 472 - mixture of Beef, meat & Pork
E 631 - Oil extracted from Pig fats.
● Note - you will find these codes mostly in products of foreign companies like :- Chips , Biscuits , Chewing Gums, Toffees, Kurkure and Maggi !
● Don't ignore pay your kind attention atleast for the well being of your kids, if in doubt then search by yourself through your sources if not internet. (Google)
● Look at ingredient on Maggi pack, you will find flavor (E-635 ).
● Also look for following codes on Google :-
E100, E110, E120, E140, E141, E153, E210, E213, E214, E216, E234, E252, E270, E280, E325, E326, E327, E334, E335, E336, E337, E422, E430, E431, E432, E433, E434, E435, E436, E440, E470, E471, E472, E473, E474, E475, E476, E477, E478, E481, E482, E483, E491, E492, E493, E494, E495, E542, E570, E572, E631, E635, E904.
We are discussing some changes to specification here: Prestaul/jsend#11
I think, specification need to be updated to define HTTP statuses too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.