nikody
Hey everyone. I have to send a JSON array with non-negative integer values, for example [100, 100], as a value in a JSON payload. How can I do this without having the list changed being charlist 'dd'?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
hauleth
These two are exactly the same thing, just different notation. So you do not need nothing.
To explain it further, difference between
[100, 100]and'dd'is the same as between255and0xff. Different notation, the same data.nikody
I understand this, but the problem is I want strictly the list with integers, not a charlist, for a value in a JSON payload. The problem is that I’m constructing a JSON payload as a map and then encoding it with Poison and the value on the other end, which is a Phoenix app too, instead of it being an array
[100, 100]is'dd'.I think the problem is actually on the receiving side. Inspecting the encoded by Poison payload seems ok, but the parameter is received with value
'dd'in the other application.I guess I’ll have to not use a list for this, but I was wondering if there is way to still use a list with strictly integers.
NobbZ
Its just representation,
true = [100, 100] === 'dd'!This will output two lines
100.hauleth
The point is that you cannot, because these two are exactly the same. It is just different print representation of them. Just for sake of this conversation assume that you decode JSON like this:
Would you be surprised when:
Would output:
Because
1e2 == 100in the same way[100, 100] == 'dd'. These two are exactly the same thing just textual representation is different.benwilson512
It’s just how your phoenix app is displaying it. You have a list of two 100 values.
jola
To help visualize this, you can try it in IEx
nikody
Thanks for the responses everyone.
I had looked through the docs, but I was still a bit confused I guess.
I understand they’re essentially the same. I was confused because I wanted to take a list of integers and join them in a string with a
-or:, for instance, and I thought that this might be a problem, but it is not.Ankhers
Just to clarify, they are not essentially the same. The are exactly the same.
Edit
Basically, because charlists are literally a list of integers (code points), the Elixir and Erlang consoles will attempt to display all integer lists as charlists (or string for erlang). It can only do this if all values are within the ascii display range. So if you had
[0, 100, 100], it would not display it as the charlist because0(being null) is outside of the ascii display range.