benonymus

benonymus

Sending generated svg ins json

Hey there,

I am trying to generate svg qr codes with this packages:

and it generates something, the svg code it seems,
and I want to send this code in json as a response, but the code that I am getting after pasting it into any svg renderer doesn’t seem to work, it doesn’t show anything.

here is the svg code: "<?xml version=\"1.0\" standalone=\"yes\"?>\n<svg version=\"1.1\" xmlns=\"http:/ - Pastebin.com

Why can this be? Or what am i missing?

EDIT:
if someone in the future would stumble upon this, you can unescape your json on this site for testing:

Marked As Solved

NobbZ

NobbZ

Well, its JSON encoded, and a JSON encoded string looks pretty much like one that is inspected.

Therefore, how to render this as SVG on the clientside, is pretty much JS stuff and nothing I could help you with.

Also Liked

NobbZ

NobbZ

If you want a pasteable output from within elixir, you need to IO.puts rather than IO.inspect.

NobbZ

NobbZ

Are you pasting exactly that code into an SVG renderer or do you print it first to resolve escapes and quotes properly?

NobbZ

NobbZ

You need to make sure its properly unquoted/unescaped first for most renderers I think…

<?xml version="1.0" standalone="yes"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" width="275" height="275"
      shape-rendering="crispEdges">
<rect width="11" height="11" x="0" y="0" style="fill:#fff"/><rect width="11" height="11" x="0" y="11" style="fill:#fff"/>
<!-- and so on -->
</svg>

How you can create an SVG from your JSON-string programmatically, I’m not sure… That massively depends on your libraries used clientside and how exactly you encode the SVG into JSON…

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
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
Tee
can someone please explain to me how Enum.reduce works with maps
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New

Other popular topics Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement