lbv/litjson — pull request #32 by prestonj (2014-11-19 20:32:20+00:00)
Title: Fix for Issue #19 - InvalidCastException when casting int to long and vice-versa

Modified handling of int and long data types. Now it is possible to cast ints to longs and vice-versa (assuming the data is within range). You can also do equality comparisons between the two. I've updated the test routine to no longer fail when comparing 10 and 10L.

Rationale: When json data is read in, litJson decides on what data type to assign to the data. For integer numerics, litjson dynamically chooses between int and long data types based on the size of the number. If it fits in an int, the data type becomes an int. However this complicates the data handling routines for the user as they cannot predetermine what type to use. Code such as the following:

long myvalue = (long) JsonData["some_number"];

would fail with an InvalidCastException when some_number was in the range of an int.

It might be worthwhile in the future to handle integer numerics using a single data type (e.g. long).