Created
July 15, 2016 11:02
-
-
Save paralleltree/e3529cda3d5eb67c312c9268c35e7e7a to your computer and use it in GitHub Desktop.
picojsonのサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 20 | |
60 20 | |
90 45 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// # picojsonでシリアライズ | |
// $ ./executable.out < coordinates | |
// [{"x":10,"y":20},{"x":60,"y":20},{"x":90,"y":45}] | |
#include <iostream> | |
#include "../picojson.h" | |
using namespace std; | |
typedef pair<int, int> point; | |
int main(void) | |
{ | |
int x, y; | |
picojson::array list; | |
while (cin >> x >> y) | |
{ | |
picojson::object value; | |
value.insert(make_pair("x", picojson::value((double)x))); | |
value.insert(make_pair("y", picojson::value((double)y))); | |
list.push_back(picojson::value(value)); | |
} | |
cout << picojson::value(list); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment