Skip to content

Parsing Issue #2

@DiogoAndreBotas

Description

@DiogoAndreBotas

Certain characters break the string in the marshal method.

Here's an example:

Actual result:

─ iex -S mix                                                                                                                                                                                                              
Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Compiling 3 files (.ex)
Interactive Elixir (1.9.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> covid_19 = %{pandemic: "{sucks}"}
%{pandemic: "{sucks}"}
iex(2)> ExNdjson.marshal!([covid_19])
"{\"pandemic\":{sucks}}\n"

Expected result:

─ iex -S mix                                                                                                                                                                                                               
Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Interactive Elixir (1.9.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> covid_19 = %{pandemic: "{sucks}"}
%{pandemic: "{sucks}"}
iex(2)> ExNdjson.marshal!([covid_19])
"{\"pandemic\":\"{sucks}\"}\n"

By simply deleting the cleanup_string function, everything seems to work. What is the objective of this method?

Proof:

image

image (1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions