Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using this library without stream ? #1370

Closed
dumarjo opened this issue Nov 22, 2018 · 7 comments
Closed

Using this library without stream ? #1370

dumarjo opened this issue Nov 22, 2018 · 7 comments

Comments

@dumarjo
Copy link
Contributor

dumarjo commented Nov 22, 2018

Hi,

I would like to use this library with our product based on Cortex-M MCU. This mcu asnot much RAM/Flash. The use of stream (fstream/streambuf) is not really an option.

Is it possible to use that libray without using stream ?

Regards

Jonathan

@nlohmann
Copy link
Owner

Assuming you mean parsing: you can also call json::parse with a string or char pointer. If that’s not what you mean, please clarify.

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Nov 23, 2018
@dumarjo
Copy link
Contributor Author

dumarjo commented Nov 23, 2018

Hi,

I would like to use this library in 2 differents way. The first one is with the data binding (DOM ?). The second one is with the SAX parser (from a json file).

The main idea is to be able to use the library with file access but not with fstream. I see the Parse method that can accept begin iterator and end iterator. The only problem, is the iterators need to be random access, but for file reading, this is somewhat not efficient.

The other problem with the json::parse with string or char * is that I cannot keep the whole json file in RAM. I need to parse it with Sax to get only the values.

Regards

Jonathan

@nlohmann nlohmann removed the state: needs more info the author of the issue needs to provide more details label Nov 23, 2018
@nlohmann
Copy link
Owner

I see. The requirement for random_access_iterator may have become unnecessary. We had a unget method in the past which was removed recently, so we could work with an input iterator. Let me check.

@dumarjo
Copy link
Contributor Author

dumarjo commented Nov 23, 2018

Hi,

Some other library offer an interface for using FILE * too. Maybe could an improvement to your library too. This is more a wish than a requirement.

Jonathan

@dumarjo
Copy link
Contributor Author

dumarjo commented Dec 11, 2018

Hi,
I have added a new input_adapter to not using the streams when working with files. I use a simple FILE * as input and everything seem to work as expected. I would like to know if this feature is desired to be added to the library ? I can make a PR if any interrest in that feature. This will eneble low end device working with file whitout the cost of the streams.

Regards
Jonathan

@nlohmann
Copy link
Owner

Yes, a PR would be really appreciated!

@nlohmann
Copy link
Owner

Closed with #1392.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants