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

How do I go about customising from_json to support __int128_t/__uint128_t? #1290

Closed
dubnde opened this issue Oct 10, 2018 · 2 comments
Closed

Comments

@dubnde
Copy link

dubnde commented Oct 10, 2018

This is really more of a question than an issue. I hope this is not too much trouble as I continue to discover what this library can help us with.

I am thinking of reading big values from a json file. I am wondering how to go about customising the from_json to support such. For instance the extended values of __int128_ and __uint128_t supported on some compilers. Or even some of those from the boost multiprecision library such as cpp_int. Is it possible to implement a from_json for such types and how would one go about it if so?

thanks once more

@dubnde dubnde changed the title How do I go about customing from_json to support __int128_t/__uint128_t? How do I go about customising from_json to support __int128_t/__uint128_t? Oct 10, 2018
@theodelrieu
Copy link
Contributor

Hello,

In theory you could specialize adl_serializer on the types you mention. However, if you want to fiddle with the internal way of serializing JSON Numbers, this is not currently possible I'm afraid.

There is an external_constructor in detail/conversions/to_json.hpp which deals with it, it is a friend of basic_json.

At the time of implementing to_json/from_json mechanism, I did not find a good way to provide such low-level support, and thought that I'd wait for a real use-case to start thinking about it :)

@dubnde
Copy link
Author

dubnde commented Oct 11, 2018

Okay. Thanks very much for the response. Your response at least clarifies I was not misreading the API.

I also think I may achieve what I need with implementing the sax parser API since it passes through the string representation of the number as a double if such a number cannot fit into int64_t or unit64_t i.e

virtual bool number_float(number_float_t val, const string_t& s) = 0;

I am okay with the number as a string.

@dubnde dubnde closed this as completed Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants