Invalid Json Response Received Roblox No ratings yet.

Posted on

You might face the invalid Json response when you supply it with incorrect values. In some cases, this can happen when calling HttpSevice’s JsonEncode method.

local a = {math.huge, math.huge * 0, 1,2,3,{4,5,6}”1\r\nhi\tuau84d0\/uwotm8″}; print(game:service(“HttpService”):JSONEncode(a))


As you are able to see, this one produces the raw Lua output for NaN and Inf. The correct way to handle this would be to encode them into null. Another thing, when you encode tables which have themselves something like a = (b = “hi”, c = “bye”) a.a = a) causes a crash. According to the Lua user on Wiki, the best way to handle it is to throw the error.

JavaScript Object Notation or Json is known as the lightweight data interchange format. This one is easy for humans to read and write. This thing is easy for machines to parse and generate. It is based on the obset of the thing called JavaScript Programming Language Standard ECMA 262 3rd Edition – December 1999.

The thing named Jason us the text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScipt, Perl, Python, and many other ones. Those properties make Json the ideal data interchange language.

Apparently, Json is built on two sctructures. The first one is the collection of name or value pairs. In various language, this one is realized as the object, record, struct, dictionary, hash table, keyed list, or associative array. The second one is the ordered list of values. In most languages, this one is realized as the array, vector, list, or sequence.

Those are the universal data structures. Virtually, each modern programming language supports them in one form or another. This one makes sense that the data format that is interchangeable with programming languages also be based on those structures.

In Json, all of them take on these forms:

  • The object is the unordered set of name or value pairs. This one begins with (left brace and ends with) right brace. Every name is followed by: colon and the name or value pairs are separated by comma.
  • The array is the ordered collection of values. This one begins with (left bracket and ends with) right bracket. All the values are separated by comma.
  • The value is able to be a string in double quotes or a number, or true or false or null, or an object or an array. Those structures are able to be nested.
  • The string is known as the sequence of zero or more Unicode characters, wrapped in double quotes, using blacklash escapes. It is stated that the character is represented as the single character string. As for the string, it is very much like a C or Java string.
  • The number is like a C or Java number. The only exception is the octal and hexadecimal formats are not used.
  • Whitespace is able to be inserted between any pair of tokens. Excepting a few encoding details, this one completely describes the language.

Please rate this

Leave a Reply

Your email address will not be published. Required fields are marked *