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

Import/Export compressed JSON files #1556

Closed
jumpy88 opened this issue Apr 1, 2019 · 6 comments
Closed

Import/Export compressed JSON files #1556

jumpy88 opened this issue Apr 1, 2019 · 6 comments
Labels
kind: enhancement/improvement state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Comments

@jumpy88
Copy link

jumpy88 commented Apr 1, 2019

I've found in the doc it's possible with this library dealing with binary JSON formats (BSON, CBOR, etc.). Anyway looking around the internet one of the most efficient ways of storing JSON files, in terms of space consumption, seems to be using standard JSON format and compress the file in a .json.gz or .json.bz2 file (as shown here and here). I understand this can be done manually with few commands and it could require to add an undesirable dependency of your json.hpp on an external compression library. On the other hand I think it would be a useful nice-to-have doing it with a single line as it is very common using compressed formats for JSON files especially in network data transmission.

@abrownsword
Copy link

IMO this would be best accomplished using a user-provided input_adapter and/or output_adapter (see #1534). This would avoid a dependency from this library to external libraries which implement the compression (or encryption since that is a fairly similar problem). Such a user-provided adapter could be provided as another library which is dependent on this one and whichever compression/encryption library (or libraries) it wants to stream using.

@jumpy88
Copy link
Author

jumpy88 commented Apr 2, 2019

Hello @abrownsword, thank you for your reply. I didn't know about the adapter design pattern (I'm studying it here, tell me if you have a better reference for that). Sorry for my lack of knowledge in design patterns. Anyway, after a quick look into, it seems it could work. Let's wait for @nlohmann opinion.

@nlohmann
Copy link
Owner

nlohmann commented Apr 2, 2019

@jumpy88 I agree with @abrownsword: We should not add a dependency to a compression library to this library, and input adapters would be the way to realize reading compressed data.

@jumpy88
Copy link
Author

jumpy88 commented Apr 2, 2019

Hello @nlohmann, as I anticipated in my first post, I too agree with avoiding dependencies which are not strictly required 🙂. So, is this something that can already be done or does it still need additional work on your side? (I've read in #1534 that you are currently working on input adapters). And if it's already usable, can you link some documented examples on how to use it?

Thank you for your support

@jumpy88
Copy link
Author

jumpy88 commented Apr 8, 2019

@nlohmann are input/output adapters already supported by json library? I couldn't find anything about this in the readme. I only find Jonathan Dumaresq implemented an input adapter to read from FILE*

@stale
Copy link

stale bot commented May 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label May 8, 2019
@stale stale bot closed this as completed May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement/improvement state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

No branches or pull requests

3 participants