csv: Allow output customization.
[nit.git] / lib / github_api.nit
index d1a66e6..39fca84 100644 (file)
@@ -45,7 +45,7 @@ class GithubCurl
 
        # Get the requested URI, and check the HTTP response. Then convert to JSON
        # and check for Github errors.
-       fun get_and_check(uri: String): nullable Object
+       fun get_and_check(uri: String): nullable Jsonable
        do
                var request = new CurlHTTPRequest(uri, self)
                request.user_agent = user_agent
@@ -53,10 +53,10 @@ class GithubCurl
                var response = request.execute
 
                if response isa CurlResponseSuccess then
-                       var obj = response.body_str.json_to_nit_object
-                       if obj isa HashMap[String, nullable Object] then
+                       var obj = response.body_str.parse_json
+                       if obj isa JsonObject then
                                if obj.keys.has("message") then
-                                       print "Message from Github API: {obj["message"]}"
+                                       print "Message from Github API: {obj["message"] or else ""}"
                                        print "Requested URI: {uri}"
                                        abort
                                end