Oct 6, 2008 at 8:40 AM
first of all, thank you for providing this framework - great work, saves me a lot of time :)
I found a bug in your JsanReader class: at line 121 you use sb.Append(_reader.Read() - offset); what causes a FormatException sometimes. I think it should work with sb.Append((char) _reader.Read());


Oct 7, 2008 at 1:06 AM
Do you mind providing me an example in which you're seeing this error?
Oct 10, 2008 at 1:22 PM
Edited Oct 10, 2008 at 1:39 PM
Hi KarlSeg!

The Json string was something like this:


it is hardly possible to provide you the whole class structure of the c# classes involved during deserialization but the vertices are a list of points with consists of values like the following:
  protected double _long;
  protected double _lat;

- for me it works fine if I change the code to the afore-mentioned one -

I think the problem is that if a number returned by read() is smaller than offset the result of StringBuilder sb maybe something like this "-12-4209..." which is obviously not convertible into a number. I also cannot understand why you are subtracting the offset from a number which (to my opinion) represents a character

hope this helps
Oct 11, 2008 at 2:21 PM
I've uploaded 0.2 which fixes the problem. I don't think your fix will work. You won't get an exception, but you won't be converting numbers correctly at all.  I've refactored the code slightly to better document what's going on. Essentially, '0' (or offset) must be subtracted from a Read value if it's expected to be a number.  If you do sb.Append(_reader.Read())  you'll append the char 1 instead of the number 1. '1' == 49.  I now detect whether the read charactr is a number and if so, subtract '0', else I append it as-is.