-- |Convenient functions for parsing JSON responses. Use these-- functions to write the 'readJSON' method of the 'JSON' class.moduleDatabase.CouchDB.JSON(jsonString,jsonInt,jsonObject,jsonField,jsonBool,jsonIsTrue)whereimportText.JSONimportData.Ratio(numerator,denominator)jsonString::JSValue->ResultStringjsonString(JSStrings)=return(fromJSStrings)jsonString_=fail"expected a string"jsonInt::(Integraln)=>JSValue->ResultnjsonInt(JSRational_r)=case(numeratorr,denominatorr)of(n,1)->return(fromIntegraln)otherwise->fail"expected an integer; got a rational"jsonInt_=fail"expected an integer"jsonObject::JSValue->Result[(String,JSValue)]jsonObject(JSObjectobj)=return(fromJSObjectobj)jsonObjectv=fail$"expected an object, got "++(showv)jsonBool::JSValue->ResultBooljsonBool(JSBoolb)=returnbjsonBoolv=fail$"expected a boolean value, got "++showv-- |Extract a field as a value of type 'a'. If the field does not-- exist or cannot be parsed as type 'a', fail.jsonField::JSONa=>String->[(String,JSValue)]->ResultajsonFieldfieldobj=caselookupfieldobjofJustv->readJSONvNothing->fail$"could not find the field "++field-- |'True' when the field is defined and is true. Otherwise, 'False'.jsonIsTrue::String->[(String,JSValue)]->ResultBooljsonIsTruefieldobj=caselookupfieldobjofJust(JSBoolTrue)->returnTrueotherwise->returnFalse