diff --git a/src/main.ml b/src/main.ml
index f52712d65036cff2e3ad7a6bc5f5092e92cc770c..38bd6e9b7f168e4c941382e89355c29004f1f9ba 100644
--- a/src/main.ml
+++ b/src/main.ml
@@ -182,7 +182,7 @@ let record_verification_result verification_result file =
     verification_result
 
 let verify_json ?memlimit ?timelimit ?outfile json =
-  let query = Json.to_query json in
+  let query = Verification_types.Query.of_json json in
   let query =
     (* Precedence to the command line option, if any. *)
     (* TODO: * get proper default value instead of defining it twice in
diff --git a/src/verification_types.ml b/src/verification_types.ml
index 7805f374c7b201e428a9b3f94db51dd7f4c26e06..a2ca2961e22e18984487f09f1db852f2d5be052e 100644
--- a/src/verification_types.ml
+++ b/src/verification_types.ml
@@ -93,6 +93,16 @@ module Query = struct
       dataset;
     }
 
+  let of_json s =
+    match of_yojson (Yojson.Safe.from_file s) with
+    | Ok t -> t
+    | Error msg ->
+      invalid_arg
+        (Fmt.str "Unrecognized JSON configuration in file '%s' (%s)" s msg)
+    | exception Yojson.Json_error msg ->
+      failwith
+        (Fmt.str "Unexpected error while parsing JSON file '%s' (%s)" s msg)
+
   let pretty fmt = Fmt.fmt "%a" fmt pp
 end