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) {
1717 return JSON . stringify ( j ) ;
1818} ;
1919
20+ exports . stringifyWithIndent = function ( i ) {
21+ return function ( j ) {
22+ return JSON . stringify ( j , null , i ) ;
23+ } ;
24+ } ;
25+
2026function isArray ( a ) {
2127 return Object . prototype . toString . call ( a ) === "[object Array]" ;
2228}
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ module Data.Argonaut.Core
3737 , jsonEmptyObject
3838 , jsonSingletonObject
3939 , stringify
40+ , stringifyWithIndent
4041 ) where
4142
4243import Prelude
@@ -178,13 +179,13 @@ toObject = toJsonType caseJsonObject
178179
179180-- Encoding
180181
181- -- | Construct `Json` from a `Boolean` value
182+ -- | Construct `Json` from a `Boolean` value
182183foreign import fromBoolean :: Boolean -> Json
183184
184- -- | Construct `Json` from a `Number` value
185+ -- | Construct `Json` from a `Number` value
185186foreign import fromNumber :: Number -> Json
186187
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
188189-- | of JSON into valid `Json`, see `jsonParser`.
189190foreign import fromString :: String -> Json
190191
@@ -235,6 +236,11 @@ jsonSingletonObject key val = fromObject (Obj.singleton key val)
235236-- | string value, see `fromString`.
236237foreign import stringify :: Json -> String
237238
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+
238244foreign import _caseJson
239245 :: forall z
240246 . Fn7
You can’t perform that action at this time.
0 commit comments