NLF

NLF

Replacing ">" and "<" with Unicode code point for. json encoding

Hello everyone after few hours of looking at docs and googling I still can’t for the love of me figure out how to mirror the json_encode in PHP json_encode with JSON_HEX_TAG which according to documentation here convert

All < and > are converted to \u003C and \u003E.

I know that using Jason_encode with the escape: :html_safe tag will will convert the ‘<’ with the proper unicode but NOT ‘>’.

What’s the most convenient way to fix this?
Thanks! :smiley:

Most Liked

03juan

03juan

Welcome to the forum :rocket:

There is an open issue about this from 20d ago, and it definitely seems like a bug. html_safe encoding bug · Issue #151 · michalmuskala/jason · GitHub

This line in the code jason/lib/encode.ex at master · michalmuskala/jason · GitHub is where the angle brackets should be encoded, and < is absent.

html_ranges​ ​=​ ​[​{​0x00​..​0x1F​,​ ​:unicode​}​,​ ​{​?<​,​ ​:unicode​}​,​ ​{​?/​,​ ​?/​}​ ​|​ ​slash_escapes​]

Last Post!

03juan

03juan

I meant ?> is missing

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement