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

Add jsone:term_to_json_string/1 as the default value of map_unknown_value option. #65

Merged
merged 1 commit into from
Sep 23, 2021

Conversation

sile
Copy link
Owner

@sile sile commented Sep 11, 2021

This PR makes it possible to encode all Erlang terms by default.

% Before: Cannot encode PID.
> {error, _} = jsone:try_encode(self()).

% After: PID (and other Erlang terms that aren't natively supported by `jsone`) are
%        encoded using the result of `io_lib:format("~p", [...]])`.
> jsone:try_encode(self()).
{ok,<<"\"<0.198.0>\"">>}

If you prefer the previous behavior, you need to specify {map_unknown_value, undefined} explicitly.

Resolves #64

@codecov-commenter
Copy link

Codecov Report

Merging #65 (7662c42) into master (f34edbc) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #65      +/-   ##
==========================================
+ Coverage   90.41%   90.44%   +0.03%     
==========================================
  Files           3        3              
  Lines         292      293       +1     
==========================================
+ Hits          264      265       +1     
  Misses         28       28              
Impacted Files Coverage Δ
src/jsone_encode.erl 86.45% <ø> (ø)
src/jsone.erl 66.66% <100.00%> (+2.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f34edbc...7662c42. Read the comment docs.

@sile
Copy link
Owner Author

sile commented Sep 11, 2021

Please let me know if there is someone who doesn't want the change of the map_unknown_value default value.
I'll merge this PR a week after if there is no such comment.

@sile sile merged commit 815a370 into master Sep 23, 2021
@sile sile deleted the map-default-unknown-value branch September 23, 2021 06:37
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

Successfully merging this pull request may close these issues.

Support for other Erlang datatypes (pid, port, func, etc)
2 participants