RESTful API/C++restSDK question

I am trying to use THIS RESTful API: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md

To do this, I am using THIS C++ SDK: https://github.com/Microsoft/cpprestsdk

The Binance API returns everything as JSON, which is where I think my issue lies.

Where I believe the error is in my code:

1
2
3
4
5
6
7
void print_test(json::value const & value){
    if(!value.is_null()){
        //I am doing something wrong here on one of these next two lines I'm pretty sure.
        auto response = value[L"responseData"];
        auto results = response[L"serverTime"];
        wcout << results.as_integer() << endl;
    }


My full code is here: https://pastebin.com/SeBAxvA0

Basically, I am trying to just test out this API by doing a simple GET method for the server time from the Binance API. According to the Binance documentation:

1
2
3
4
5
6
7
8
9
10
11
12
 Check server time
    GET /api/v1/time
    Test connectivity to the Rest API and get the current server time.

    Weight: 1

    Parameters: NONE

    Response:
    {
      "serverTime": 1499827319559
    }


So I would like to do a GET request for that JSON, and then have my C++ program output the value of serverTime. When I try to run my code as is, I get an error saying:

1
2
3
 error: no viable overloaded operator[] for type
      'const json::value'
        auto response = value[L"responseData"];

However, I am following along with an example from the C++restSDK found here: http://mariusbancila.ro/blog/2013/08/02/cpp-rest-sdk-in-visual-studio-2013/

I think my issue has something to do with the two lines under the comment I made on line 45 in my pastebin. Presumably, I am assigning the wrong values to one or both of the variables under that line. I know this is a pretty specific help request, but does anyone know what I'm doing wrong and how to get the value of servertime to display?
Last edited on
I solved this issue on my own after much digging :)
Error was in this function and it is now fixed with this code:

1
2
3
4
5
6
void print_test(json::value const & value){
        if(!value.is_null()){
            json::value test = value;
            cout << test["serverTime"] << endl;
        }
    }
Last edited on
Topic archived. No new replies allowed.