There is no JSON datatype "decimal number"

One of the quizzes asks for the JSON datatypes to be checked. The course gives the answer that ‘decimal number’ is a JSON datatype. It then says if you got this wrong, read the json spec. I surely did not find it there. Instead, I find the datatype ‘number’. Did I not find something, or is the answer given in the quiz as correct actually wrong, or does the teaching of Mongo eschew the precision of the disciplines of computer science and engineering and encourage people to say decimal number when they mean number. If only JSON validators were that forgiving.

JSON.org links to the JSON grammar specification in McKeeman Form.

The “number” grammar is defined as “integer fraction exponent”, where each of those grammars are further specified in the document.

So it’s perfectly correct to say that JSON supports decimal numbers, because decimal is just a sub-type of supported numbers.

You are right, that mongo supports decimal numbers, since of course decimal numbers are included in number. If that was the question, what types of data does mongo support? then decimal numbers would be among them. But the question was “which of the following data types are directly supported by JSON?” It is asking about data types, not about subtypes of datatypes. For example, if you asked "does mongo DB directly support the datatype: String that begins with an ‘a’, someone might say, no, there is no such a datatype, even though of course strings that begin with an ‘a’ are among those strings of the datatype string. Similarly, does mongo directly support the datatype of decimal numbers with four digits after the decimal? This would not show a lack of knowledge of datatypes, but rather a person who interpreted questions very strictly.

Hi @William_Frank_90755,

In addition to what @Paul_16877,

If you go to the JSON spec, you can see number is the umbrella term used to represent integer, fraction and exponent. So, all these types are inherently supported by JSON.

17%20PM

I would recommend you to have a holistic approach whenever you are solving the quizzes or labs.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Shuban, of course, indirectly. I thought that was a given. Only, the question said does it ‘support this datatype’. it says nothing about ‘indirectly’. The issue is, the specification of a grammatically well formed string of a given type, (and I know it is not a string, but it is a meta-string ,as all JS is untimately strings in its metalanguage) which your railroad tracks digram shows, is entirely different from what the datatype is. It so happens that there are only two numberish datatypes, number and integer. The fact that number includes decimal numbers is separate from what the datatypes are. The question could be reworded to say, includes numbers in the form of decimal numbers, or include the word ‘indirectly’, and then it would be worded clearly and umambiguously.

The JS datatype string includes ‘support’ for all strings beginning with an h, which you can also see in the railroad track spec for string. This does not mean that JS supports the datatype 'strings beginning wiht an “s”.

So, the issue I am trying to raise is not at all with whether what mongo intends to say about decimal numbers is correct. You surely know this area, far better than I. It is about how the question is worded, when it would be so easy to change the wording so that people who were precise about language could get it right. True/false questions especially need precise statements. Framing questions, and the theory of strings, are things where I do have a large body of knowledge and experience.

As for a wholistic approach, I can try to squint and think only vaguely about what the question means, and thus have it more likely that I am guessing the answer you guys have in mind. Or I can think more like a json validator, which would not hesitate to say there is no ‘decimal number’ datatype. Is it not computer science we are talking about? Why not adjust some of the questiosn to make them more precisely true or false?

Wm

But then there may be people arguing in the other direction; that JSON does not in fact support numbers. After all, surds, imaginary and complex numbers exist, and they cannot be represented using JSON’s number grammars.

I believe the question is intended to convey to the student that both integer and decimal numbers can be represented using JSON, and for a foundation-level course I think this is appropriate.


Paul_16877

    September 23

But then there may be people arguing in the other direction; that JSON does not in fact support numbers. After all, surds, imaginary and complex numbers exist, and they cannot be represented using JSON’s number grammars.

Good points, and you are right, the intent of the question is to make sure people know the scope of number as a datatype. Also, I had forgotten all about surds, and what they are. Thanks.

But it would take only a very few words, maybe one, to make the question folly accurate, and it would not make it harder to understand, even at the foundation level. Me, I am a logic chopper, and often annoy people as result. In science, I have often found that it does no harm and sometimes help to use the exact right words.