modified fromjson to make the parser work with an input stream instead
of a char pointer.