Fix a few parsing bugs that can allow for silent truncation of valid JSO...

...N

Currently, the CFEngine JSON parser plays pretty fast and loose with the JSON spec. This minor change introduces some more intelligent sanity checking on the validity of the JSON structures being read in.

Since currently (though I don't think this should be the case), CFEngine will silently truncate JSON files that are larger than the max length specified in a call to readjson or similar, the only hope for catching that truncation is if it introduces a syntax error.

I would like to make trailing commas cause an error per the JSON spec, but that tends to be much more divisive.

I'd also like to ask why you rolled your own JSON parser, rather than using one lik c-json or jansson?