-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
52 lines (43 loc) · 1.25 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <thread>
#include <sstream>
#include "json.h"
#include "http.h"
using namespace std;
int main()
{
string json = _http::get("https://www.cbr-xml-daily.ru/latest.js");
_json::node *myfuckingjsonparser = _json::json::build(json);
_json::json_primitive *date = myfuckingjsonparser->_get<_json::json_primitive *>("date");
cout << date->value << " ";
cout << "(" << _json::JSON_DATA_TYPE_STRING.at(date->dataType) << ")" << "\n";
cout << "1 usd - " << 1 / stod(myfuckingjsonparser->_get<_json::json_primitive *>("rates.USD")->value) << "rub" << "\n";
return 0;
/*
ifstream myfile("input.json");
string kek;
if (myfile.is_open())
{ // always check whether the file is open
char mychar;
while (myfile)
{
mychar = myfile.get();
kek += mychar;
}
}
_json::node *asd = _json::json::build(kek);
//foreach
_json::node *a = asd->_get<_json::node *>("menu.popup.menuitem");
for (int i = 0; i <= size(a->childrenArray) - 1; i++)
{
cout << a->childrenArray[i]->_get<_json::json_primitive *>("onclick")->value << "\n";
}
//get arr item
_json::json_primitive *item = asd->_get<_json::json_primitive *>("menu.arr.0.0");
cout << item->value << "\n";
*/
}