Quantcast
Channel: Chilkat Forum - latest questions
Viewing all articles
Browse latest Browse all 1061

Download malformed json on armv7a-hardfp-linux

$
0
0

Using: chilkat-9.5.0-armv7a-hardfp-linux OS: Raspbian on Raspberry Pi 3 On raspbian, this simple code to download a .json file gets malformed data, looks like the data it's downloaded as Binary. Same code on mingw64 download correct .json data. Is there something wrong in my code?

#include <cstdio>
#include <iostream>
#include <ctime>
#include <CkHttpW.h>
#include <CkGlobalW.h>

std::string getGmtTime();

int main()
{
    CkGlobalW glob;
    bool success = glob.UnlockBundle(L"Anything for 30-day trial");
    // Download json
    CkHttpW http;
    bool geturl;
    wchar_t usgsUrl[1000];
    swprintf(usgsUrl, 1000, L"http://earthquake.usgs.gov/fdsnws/event/1/query.geojson?starttime=%s&minmagnitude=2.5&orderby=time", getGmtTime().c_str());
    const wchar_t *localFilePath = (L"data/json/Catalog.json");
    geturl = http.Download(usgsUrl, localFilePath);
    //  If error
    if (geturl != true) {
        wprintf(L"http.lastErrorText()");
        return 0;
    }
}

std::string getGmtTime()
{
    std::time_t now = std::time(0);
    std::tm* now_tm = std::gmtime(&now);
    char buf[42];
    std::strftime(buf, 42, "%Y-%m-%d", now_tm);
    return (buf);
}

alt text


Viewing all articles
Browse latest Browse all 1061

Trending Articles