diff --git a/README.md b/README.md index 94e5cdc..fd814e8 100644 --- a/README.md +++ b/README.md @@ -231,14 +231,19 @@ iex> Fiz.Foo.json_decode("{\"a\":42}") iex> Fiz.Foo.json_decode!("{\"a\":42}") ``` - ### JSON library configuration -By default, `protox` uses [`Jason`](https://github.com/michalmuskala/jason) to encode values to JSON (mostly to escape strings). You can also use [`Poison`](https://github.com/devinus/poison): +By default, `protox` uses [`Jason`](https://github.com/michalmuskala/jason) to encode values to JSON. You can also use [`Poison`](https://github.com/devinus/poison) by configuring the `json_library` option: ```elixir -iex> Protox.json_decode!(iodata, Fiz.Foo, json_library: Protox.Poison) -iex> Protox.json_encode!(msg, json_library: Protox.Poison) +defmodule MyModule do + use Protox, schema: """ + syntax = "proto3"; + + message Foo {} + """, + json_library: Poison # or Jason +end ``` ℹ️ You can use any other library by implementing the `Protox.JsonLibrary` behaviour. diff --git a/lib/protox.ex b/lib/protox.ex index 5092016..49d4acb 100644 --- a/lib/protox.ex +++ b/lib/protox.ex @@ -157,9 +157,6 @@ defmodule Protox do ## Errors This function returns a tuple `{:error, reason}` if: - `input` could not be decoded to JSON; `reason` is a `Protox.JsonDecodingError` error - - ## JSON library configuration - TODO: document json library configuration """ @doc since: "2.0.0" @spec json_decode(iodata(), atom()) :: {:ok, struct()} | {:error, any()} @@ -198,13 +195,6 @@ defmodule Protox do iex> {:ok, iodata} = msg |> Protox.json_encode() iex> :binary.list_to_bin(iodata) "{\\"msgK\\":{\\"2\\":\\"bar\\",\\"1\\":\\"foo\\"}}" - - ## JSON library configuration - TODO: document the json library configuration - - ## Encoding specifications - See https://developers.google.com/protocol-buffers/docs/proto3#json for the specifications - of the encoding. """ @doc since: "2.0.0" @spec json_encode(struct()) :: {:ok, iodata()} | {:error, any()}