Skip to content

Instantly share code, notes, and snippets.

@paralleltree
Created July 15, 2016 11:02
Show Gist options
  • Save paralleltree/e3529cda3d5eb67c312c9268c35e7e7a to your computer and use it in GitHub Desktop.
Save paralleltree/e3529cda3d5eb67c312c9268c35e7e7a to your computer and use it in GitHub Desktop.
picojsonのサンプル
10 20
60 20
90 45
// # 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