Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

Fix parsing from std::cin (tellg/seekg are not working for it).#62

Open
SergiusTheBest wants to merge 1 commit intohjiang:masterfrom
SergiusTheBest:master
Open

Fix parsing from std::cin (tellg/seekg are not working for it).#62
SergiusTheBest wants to merge 1 commit intohjiang:masterfrom
SergiusTheBest:master

Conversation

@SergiusTheBest
Copy link

Hi there,

I fixed parsing from std::cin. The problem was in tellg/seekg that break std::cin (and it looks they are not required at all, so I removed them).

You can reproduce the issue with the following sample:

#include "jsonxx.h"
#include <iostream>

using namespace std;
using namespace jsonxx;

int main()
{
    Object o;
    o.parse(cin);
    cout << o.get<Array>("ar").get<Number>(0) << endl;
    return 0;
}

Send this json to stdin:

{ "ar" : [1] }

@hjiang
Copy link
Owner

hjiang commented Mar 2, 2017

This change would break the test at jsonxx_test.cc:171 on macOS.

But it seems to work fine on Linux. Interesting.

@SergiusTheBest
Copy link
Author

I checked on Windows and Linux. So it looks it depends on istream implementation.

@SergiusTheBest
Copy link
Author

By the way, thanks for the good library. It's small and very easy to use. Nice work!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants