Giter VIP home page Giter VIP logo

elixir-jsonpointer's Issues

** (FunctionClauseError) no function clause matching in JSONPointer.walk_container/7

The following code

data = Jason.decode!(~s({"one":1,"two":2,"array":[1,2,3], "dict":{"four": "4", "five": "5"}}))
JSONPointer.get( data, "/array/0/1" )

returns:
** (FunctionClauseError) no function clause matching in JSONPointer.walk_container/7

Can it be updated to return an error tuple? something like:

{:error, "no function clause matching"}

Screen Shot 2022-12-19 at 7 21 01 PM

nice library btw

"/c%d" incorrectly identified as "malformed URI"

According to the spec /c%d should be a valid query string. See the following IEx session for details.

Erlang/OTP 21 [erts-10.0.7] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> doc = ~S"""
...(1)>    {
...(1)>       "foo": ["bar", "baz"],
...(1)>       "": 0,
...(1)>       "a/b": 1,
...(1)>       "c%d": 2,
...(1)>       "e^f": 3,
...(1)>       "g|h": 4,
...(1)>       "i\\j": 5,
...(1)>       "k\"l": 6,
...(1)>       " ": 7,
...(1)>       "m~n": 8
...(1)>    }
...(1)> """
"   {\n      \"foo\": [\"bar\", \"baz\"],\n      \"\": 0,\n      \"a/b\": 1,\n      \"c%d\": 2,\n      \"e^f\": 3,\n      \"g|h\": 4,\n      \"i\\\\j\": 5,\n      \"k\\\"l\": 6,\n      \" \": 7,\n      \"m~n\": 8\n   }\n"
iex(2)> map = Jason.decode!(doc)
%{
  "" => 0,
  " " => 7,
  "a/b" => 1,
  "c%d" => 2,
  "e^f" => 3,
  "foo" => ["bar", "baz"],
  "g|h" => 4,
  "i\\j" => 5,
  "k\"l" => 6,
  "m~n" => 8
}
iex(3)> JSONPointer.get(map, "/c%d")
** (ArgumentError) malformed URI "c%d"
    (elixir) lib/uri.ex:334: URI.decode/1
    (elixir) lib/enum.ex:1314: Enum."-map/2-lists^map/1-0-"/2
    (odgn_json_pointer) lib/json_pointer.ex:859: JSONPointer.parse/1
    (odgn_json_pointer) lib/json_pointer.ex:441: JSONPointer.walk_container/4
    (odgn_json_pointer) lib/json_pointer.ex:72: JSONPointer.get/2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.