Commit 72476c41 authored by Camil Staps's avatar Camil Staps

Merge branch 'trim-json-fromstring' into 'master'

Trim strings in JSONNode fromString instance

See merge request !282
parents 486c945b 80043023
Pipeline #30186 passed with stage
in 3 minutes and 5 seconds
...@@ -10,7 +10,7 @@ definition module Text.GenJSON ...@@ -10,7 +10,7 @@ definition module Text.GenJSON
* *
* @property-bootstrap * @property-bootstrap
* import StdEnv * import StdEnv
* import Data.GenEq * import Data.GenEq, Text
* *
* :: TestRecord = {a :: Int, b` :: [(Int,[Char])]} * :: TestRecord = {a :: Int, b` :: [(Int,[Char])]}
* *
...@@ -74,6 +74,7 @@ instance toString JSONNode ...@@ -74,6 +74,7 @@ instance toString JSONNode
* @property error for incomplete parsings: A.x :: type; s :: String: * @property error for incomplete parsings: A.x :: type; s :: String:
* let json = toJSON x in * let json = toJSON x in
* toInt s == 0 ==> // we may append more digits to an int, in which case it is not invalid * toInt s == 0 ==> // we may append more digits to an int, in which case it is not invalid
* trim s <> "" ==> // if we only add whitespace it is not invalid
* size s > 0 ==> * size s > 0 ==>
* fromString (toString json +++ s) =.= JSONError * fromString (toString json +++ s) =.= JSONError
*/ */
......
...@@ -182,8 +182,9 @@ where ...@@ -182,8 +182,9 @@ where
instance fromString JSONNode instance fromString JSONNode
where where
fromString s fromString s
# (json,i) = parse 0 s # s` = trim s
| i == size s # (json,i) = parse 0 s`
| i == size s`
= json = json
= JSONError = JSONError
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment