Skip to content

Commit 0566640

Browse files
committed
Added dependency from json-value
1 parent a093db8 commit 0566640

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

elm-package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
],
1010
"exposed-modules": [],
1111
"dependencies": {
12+
"1602/json-value": "1.0.0 <= v < 2.0.0",
1213
"NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
1314
"elm-community/json-extra": "2.0.0 <= v < 3.0.0",
1415
"elm-community/list-extra": "6.1.0 <= v < 7.0.0",

src/EditableJsonValue.elm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module EditableJsonValue exposing (EditableJsonValue(..), makeEditableJsonValue, makeJsonValue)
22

3-
import Json.Schema.Definitions as Schema
3+
import JsonValue
44
exposing
55
( JsonValue
66
( ObjectValue
77
, ArrayValue
8-
, BooleanValue
8+
, BoolValue
99
, NullValue
1010
, NumericValue
1111
, StringValue
@@ -34,7 +34,7 @@ makeEditableJsonValue jsonValue =
3434
NumericValue n ->
3535
NumericEValue n
3636

37-
BooleanValue b ->
37+
BoolValue b ->
3838
BoolEValue b
3939

4040
NullValue ->
@@ -61,7 +61,7 @@ makeJsonValue editableJsonValue =
6161
NumericValue n
6262

6363
BoolEValue b ->
64-
BooleanValue b
64+
BoolValue b
6565

6666
NullEValue ->
6767
NullValue

src/JsonInput.elm

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,14 @@ import Helpers
6868
, setPropertyNameInJsonValue
6969
)
7070
import Validation
71+
import JsonValue exposing (JsonValue(ObjectValue, ArrayValue))
7172
import Json.Schema.Definitions as Schema
7273
exposing
7374
( Schema(BooleanSchema, ObjectSchema)
7475
, SubSchema
7576
, Schemata(Schemata)
7677
, Type(AnyType, SingleType, NullableType, UnionType)
7778
, SingleType(IntegerType, NumberType, StringType, BooleanType)
78-
, JsonValue(ObjectValue, ArrayValue, BooleanValue, NullValue, NumericValue, StringValue)
79-
, jsonValueDecoder
80-
, encodeJsonValue
81-
, blankSchema
8279
)
8380
import EditableJsonValue
8481
exposing
@@ -139,7 +136,7 @@ init schema val =
139136
let
140137
jsonValue =
141138
val
142-
|> Decode.decodeValue jsonValueDecoder
139+
|> Decode.decodeValue JsonValue.decoder
143140
|> Result.withDefault (ObjectValue [])
144141

145142
editableJsonValue =
@@ -169,7 +166,7 @@ makeValidSchema jsonValue schema =
169166
let
170167
val =
171168
jsonValue
172-
|> encodeJsonValue
169+
|> JsonValue.encode
173170
in
174171
schema
175172
|> Validation.validate val
@@ -180,7 +177,7 @@ makeValidSchema jsonValue schema =
180177
getValue : Model -> Value
181178
getValue model =
182179
model.jsonValue
183-
|> encodeJsonValue
180+
|> JsonValue.encode
184181

185182

186183
updateValue : Model -> String -> Result String EditableJsonValue -> ( Model, ExternalMsg )
@@ -256,7 +253,7 @@ update msg model =
256253
|> getJsonValue (parseJsonPointer jsonPointer)
257254
|> Result.withDefault model.editableJsonValue
258255
|> EditableJsonValue.makeJsonValue
259-
|> encodeJsonValue
256+
|> JsonValue.encode
260257
|> Encode.encode 4
261258
}
262259
, Select id
@@ -274,7 +271,7 @@ update msg model =
274271
-}
275272
ValueChange path str ->
276273
str
277-
|> decodeString jsonValueDecoder
274+
|> decodeString JsonValue.decoder
278275
|> Result.map EditableJsonValue.makeEditableJsonValue
279276
|> updateValue { model | editValue = str, editPath = path } path
280277

@@ -356,7 +353,7 @@ update msg model =
356353
( { model
357354
| jsonValue =
358355
s
359-
|> Decode.decodeValue jsonValueDecoder
356+
|> Decode.decodeValue JsonValue.decoder
360357
|> Result.withDefault (ObjectValue [])
361358
}
362359
, NoOp

0 commit comments

Comments
 (0)