-
Notifications
You must be signed in to change notification settings - Fork 35
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
Escaped HTML characters in output #58
Comments
I don't think this matters much in practice, it seems like most clients are able to handle it. |
Hi @emptyflask ! Sorry for not getting in touch about this PR! Some questions before I can dig in, I assume you serialize ActiveRecord objects:
|
@emptyflask hi! can you give any answers to the questions I asked? I think this is a quick one to fix, just need your input here so I can reproduce it correctly. |
Oh, sorry, I got buried with other stuff and forgot to respond to this. I will have to do some testing again, but I believe this was with Rails 5.x and PostgreSQL, and |
Ruby 2.6.3 class FooSerializer < Panko::Serializer
attributes :body
end
FooSerializer.new.serialize(Struct.new(:body).new("<p> </p>")).to_json
# => {"body":"\u003cp\u003e\u0026nbsp;\u003c/p\u003e"} |
Hi @yosiat, I encountered the same issue and found that monkey patching the gem resolves it. module Panko
class ArraySerializer
def serialize_to_json(subjects)
serialize_with_writer(subjects, Oj::StringWriter.new(mode: :custom)).to_s
end
end
end
module Panko
class Serializer
def serialize_to_json(object)
serialize_with_writer(object, Oj::StringWriter.new(mode: :custom)).to_s
end
end
end |
Even with
Oj.mimic_JSON
set, there doesn't seem to be a way to output the non-escaped characters.It doesn't seem to be due to the Oj::StringWriter, so perhaps this is happening at a lower level:
The text was updated successfully, but these errors were encountered: