File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ exports.stringify = function (j) {
17
17
return JSON . stringify ( j ) ;
18
18
} ;
19
19
20
+ exports . stringifyWithIndent = function ( i ) {
21
+ return function ( j ) {
22
+ return JSON . stringify ( j , null , i ) ;
23
+ } ;
24
+ } ;
25
+
20
26
function isArray ( a ) {
21
27
return Object . prototype . toString . call ( a ) === "[object Array]" ;
22
28
}
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ module Data.Argonaut.Core
37
37
, jsonEmptyObject
38
38
, jsonSingletonObject
39
39
, stringify
40
+ , stringifyWithIndent
40
41
) where
41
42
42
43
import Prelude
@@ -178,13 +179,13 @@ toObject = toJsonType caseJsonObject
178
179
179
180
-- Encoding
180
181
181
- -- | Construct `Json` from a `Boolean` value
182
+ -- | Construct `Json` from a `Boolean` value
182
183
foreign import fromBoolean :: Boolean -> Json
183
184
184
- -- | Construct `Json` from a `Number` value
185
+ -- | Construct `Json` from a `Number` value
185
186
foreign import fromNumber :: Number -> Json
186
187
187
- -- | Construct `Json` from a `String` value. If you would like to parse a string
188
+ -- | Construct `Json` from a `String` value. If you would like to parse a string
188
189
-- | of JSON into valid `Json`, see `jsonParser`.
189
190
foreign import fromString :: String -> Json
190
191
@@ -235,6 +236,11 @@ jsonSingletonObject key val = fromObject (Obj.singleton key val)
235
236
-- | string value, see `fromString`.
236
237
foreign import stringify :: Json -> String
237
238
239
+ -- | Converts a `Json` value to a JSON string.
240
+ -- | The first `Int` argument specifies the amount of white space characters to use as indentation.
241
+ -- | This number is capped at 10 (if it is greater, the value is just 10). Values less than 1 indicate that no space should be used.
242
+ foreign import stringifyWithIndent :: Int -> Json -> String
243
+
238
244
foreign import _caseJson
239
245
:: forall z
240
246
. Fn7
You can’t perform that action at this time.
0 commit comments