fix as_json serialization
Merge pull request #574 from ilvalle/fix-serialization

fix issue 2027: bug in query serialization