Test case
1 generated file · +5 −1test/inputs/json/misc/ed095.json
Melixirdefault / QuickType.ex+5 −1
| @@ -6,8 +6,12 @@ | ||
| 6 | 6 | # Encode into a JSON string: TopLevel.to_json(struct) |
| 7 | 7 | |
| 8 | 8 | defmodule TopLevel do |
| 9 | + def decode_value(value) when is_map(value), do: value | |
| 10 | + | |
| 9 | 11 | def from_json(json) do |
| 10 | - Jason.decode!(json) | |
| 12 | + json | |
| 13 | + |> Jason.decode!() | |
| 14 | + |> decode_value() | |
| 11 | 15 | end |
| 12 | 16 | |
| 13 | 17 | def to_json(data) do |
Test case
1 generated file · +5 −1test/inputs/json/priority/bug855-short.json
Melixirdefault / QuickType.ex+5 −1
| @@ -51,8 +51,12 @@ defmodule TopLevelValue do | ||
| 51 | 51 | end |
| 52 | 52 | |
| 53 | 53 | defmodule TopLevel do |
| 54 | + def decode_value(value) when is_map(value), do: value | |
| 55 | + | |
| 54 | 56 | def from_json(json) do |
| 55 | - Jason.decode!(json) | |
| 57 | + json | |
| 58 | + |> Jason.decode!() | |
| 59 | + |> decode_value() | |
| 56 | 60 | end |
| 57 | 61 | |
| 58 | 62 | def to_json(data) do |
Test case
1 generated file · +2 −1test/inputs/json/priority/no-classes.json
Melixirdefault / QuickType.ex+2 −1
| @@ -7,7 +7,8 @@ | ||
| 7 | 7 | |
| 8 | 8 | defmodule TopLevel do |
| 9 | 9 | def from_json(json) do |
| 10 | - Jason.decode!(json) | |
| 10 | + json | |
| 11 | + |> Jason.decode!() | |
| 11 | 12 | end |
| 12 | 13 | |
| 13 | 14 | def to_json(data) do |
Test case
1 generated file · +20 −0test/inputs/schema/empty-object.schema
Aschema-elixirdefault / QuickType.ex+20 −0
| @@ -0,0 +1,20 @@ | ||
| 1 | +# This file was autogenerated using quicktype https://github.com/quicktype/quicktype | |
| 2 | +# | |
| 3 | +# Add Jason to your mix.exs | |
| 4 | +# | |
| 5 | +# Decode a JSON string: TopLevel.from_json(data) | |
| 6 | +# Encode into a JSON string: TopLevel.to_json(struct) | |
| 7 | + | |
| 8 | +defmodule TopLevel do | |
| 9 | + def decode_value(value) when is_map(value), do: value | |
| 10 | + | |
| 11 | + def from_json(json) do | |
| 12 | + json | |
| 13 | + |> Jason.decode!() | |
| 14 | + |> decode_value() | |
| 15 | + end | |
| 16 | + | |
| 17 | + def to_json(data) do | |
| 18 | + Jason.encode!(data) | |
| 19 | + end | |
| 20 | +end |
Test case
1 generated file · +2 −1test/inputs/schema/top-level-primitive.schema
Mschema-elixirdefault / QuickType.ex+2 −1
| @@ -11,7 +11,8 @@ defmodule TopLevel do | ||
| 11 | 11 | """ |
| 12 | 12 | |
| 13 | 13 | def from_json(json) do |
| 14 | - Jason.decode!(json) | |
| 14 | + json | |
| 15 | + |> Jason.decode!() | |
| 15 | 16 | end |
| 16 | 17 | |
| 17 | 18 | def to_json(data) do |
No generated files match these filters.