Reading bool values

Nov 18, 2008 at 6:06 AM
Hi Karl,

Thank you so much for this code. Very much appreciated.
However, when I use the software it seems that bool values will serialize but not deserialize.

To make things work they way I need I've added the following to a local copy of the code

------------- in JsonReader.cs ----------------------------
        public virtual bool ReadBool()
            string str = ReadNonStringValue('\0');
            if (str == null) return false;
            if (str.Equals("true"))return true;
            if (str.Equals("false"))return false;
            throw new JsonException("Expecting true or false, but got "+str);
------------- and in JsonDeserializer.DeserializeValue ----------------------
            if (type == typeof(bool))
                return _reader.ReadBool();


Would you like me to take things further?

Cheers Greg

Nov 19, 2008 at 12:54 AM
Thanks for the suggestion. I've implemented your change and its now in the repository.

I built this library for use in a new project, and priorities got changed on me. So I haven't been able to put this code to the test or add features. Hopefully I'll get to pick it up again (although it should provide a good foundation as-is). If you come up with anything else, please do let me know.