Open Taddic opened 10 years ago
Hi Tommy, I'm so sorry! Somehow I missed your message.
When creating Erlson, I didn't want to step too far from Erlang syntax and tried to add as little changes as possible. Syntax support I've added so far generally follow Erlang semantics. Adding syntax for list element access would mean introducing a new operation that's not present in Erlang. I'd prefer to avoid that.
On the other hand, adding the ability to address individual list elements in the erlson:store()
and erlson:get_value()
may be useful.
The only thing I'm worried about is that setting list element by its integer position is not really a functional interface. Naturally, you won't find such functions in the lists
module. In theory, we could restrict the set operation to be applicable to only those integer indexes that are already present in the list, but it may lead to even more confusion as it would be clearly more restrictive compared to setting/adding dictionary elements by name.
Now, if for these reasons we rule out the API for setting list elements by an int, should we event bother extending get_value
to support getting list elements?
Hi Alavrik,
I would like to use your library for a project. I have looked through your code and tested it and I like it overall. I have one small problem though, I haven't been able to figure out how to make this type of query: "attr1[0].attr2" but using your notation. Does your library support to make such queries?
What I would like to be able to do is the following: Search for or replace a value at let's say position
"attr1[0].attr2"
in for instance this json object:{attr1 : [{attr2 : value1}, {attr2 : value2}]}
In a more erlang fashion it would be like this.
and similarly for
erlang erlson:get_value/2
, where it would just return"value1"
Keep up the good work :) Cheers, /Tommy