Skip to content

Instantly share code, notes, and snippets.

@joewilliams
Created September 19, 2009 23:47

Revisions

  1. joewilliams created this gist Sep 19, 2009.
    22 changes: 22 additions & 0 deletions print_http_json.ml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    (*
    to compile:
    $ ocamlfind ocamlopt -o print_http_json print_http_json.ml -linkpkg -package json-static,netclient -syntax camlp4o
    to run (trying it out on couchdb):
    $ ./print_http_json http://localhost:5984/joetest
    *)

    open Printf

    let get url =
    (Json_io.json_of_string
    (Http_client.Convenience.http_get url ))

    let print json =
    printf "%s\n%!"
    (Json_io.string_of_json ~compact:false json)

    let _ =
    print (get(Sys.argv.(1)))