Querying json objects

I’m looking for a way to query specific values from a json api response’s.
a bit xpath like query language.

I was thinking, transform the json to xml, run the xpath’s and return the results. :grimacing:

is there a suitable library out there?

There is RFC 6901 which defines JSON Pointer specification. With that term I have found something like that - https://github.com/odogono/elixir-jsonpointer.

4 Likes

I am working to port Stefan Goessner JsonPath implementation to elixir, but it still in development stage.

3 Likes

Kernel.get_in/2 can meet basic needs

5 Likes

I use jsn for json path queries:

% #{<<"user">> => #{<<"activated">> => true,
%                   <<"id">> => <<"123">>,
%                   <<"name">> => #{<<"first">> => <<"Jane">>,
%                                   <<"last">> => <<"Doe">>}}}

% get the user id
UserId = jsn:get('user.id', User).
% <<"123">>

thanks, I will try pointer & json path :slightly_smiling_face:

The first version of Warpath released.

3 Likes