Maybe do something like this instead so we return only {"count":value} 

CountValue = lib_json:get_field(EncodedResult, "count")
ReturnJson = lib_json:set_attr("count", countValue)
{ReturnJson, ReqData, State};