Problems with elastic search querying when using libcurl

Hello All,
I am using libcurl to retrieve my indexed results. I have problems
with the following code.
http://pastebin.com/NgdTBTAb

The same code with out "to" in the range query seems to work fine. [code
here: http://pastebin.com/DYi10upZ]
I tried its curl variation (below) and it seemed to retrieve all the
results.

curl -XGET http://localhost:9202/_all/_search?pretty=true -d '{
"size": 1000000,
"query" : {
"range" : {
"snapshotTime" : {
"from" : "2012-10-31T13:00:00",
"to" : "2012-10-31T14:00:00"
}
}
}
}'

Is there something wrong with the way I am querying?
In case if there is a better library (C/C++) that suits elastic search
needs, do let me know.
Thanks.

--

By problems in the first code, I mean, I don't get any results back. The
total_hits remain 0. However, its curl version works fine retrieving all
the results.

--