Skip to content

Commit 5572b7f

Browse files
committed
Initial commit
0 parents  commit 5572b7f

10 files changed

Lines changed: 2468 additions & 0 deletions

File tree

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
dist
2+
dist-*
3+
cabal-dev
4+
*.o
5+
*.hi
6+
*.chi
7+
*.chs.h
8+
*.dyn_o
9+
*.dyn_hi
10+
.hpc
11+
.hsenv
12+
.cabal-sandbox/
13+
cabal.sandbox.config
14+
*.prof
15+
*.aux
16+
*.hp
17+
*.eventlog
18+
.stack-work/
19+
cabal.project.local
20+
cabal.project.local~
21+
.HTF/
22+
.ghc.environment.*
23+
stack.yaml
24+
*.swm
25+
*.swo
26+
*.swp
27+
test_results/**
28+
cabal.project.local

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for json-syntax
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.

LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 2019, Andrew Martin
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Andrew Martin nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# json-syntax
2+
3+
This library parses JSON into a `Value` type that is consistent with the
4+
ABNF described in [RFC 7159](https://tools.ietf.org/html/rfc7159). The
5+
parser is about six times faster than the parser that `aeson` provides.
6+
This parser is however, non-resumable, so if resumable parsing is
7+
important, `aeson` should be preferred. Results from the benchmark suite:
8+
9+
benchmarked json/twitter/100
10+
time 208.6 μs (207.1 μs .. 210.1 μs)
11+
1.000 R² (0.999 R² .. 1.000 R²)
12+
mean 211.8 μs (210.7 μs .. 213.3 μs)
13+
std dev 4.493 μs (3.299 μs .. 7.422 μs)
14+
15+
benchmarked aeson/twitter/100
16+
time 1.284 ms (1.267 ms .. 1.296 ms)
17+
0.999 R² (0.999 R² .. 1.000 R²)
18+
mean 1.282 ms (1.276 ms .. 1.292 ms)
19+
std dev 26.07 μs (17.87 μs .. 40.01 μs)
20+
21+
This library does not include any functions or typeclasses to help users
22+
convert data from `Value`, the RFC-7159-inspired syntax tree data type.
23+
Such functions and typeclasses are outside the scope of this library. If
24+
anyone writes a library that helps users marshal their data in this way,
25+
open a issue so that the `json-syntax` documentation can point users to it.

Setup.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

bench/Main.hs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{-# LANGUAGE BangPatterns #-}
2+
{-# LANGUAGE TypeApplications #-}
3+
4+
import Gauge.Main (defaultMain,bgroup,bench,whnf)
5+
6+
import Twitter100 (encodedTwitter100,byteStringTwitter100)
7+
8+
import qualified Data.Bytes as Bytes
9+
import qualified Json as J
10+
import qualified Data.Aeson as Aeson
11+
12+
main :: IO ()
13+
main = defaultMain
14+
[ bgroup "json"
15+
[ bgroup "twitter"
16+
[ bench "100" $ whnf
17+
(\b -> J.decode (Bytes.fromByteArray b))
18+
encodedTwitter100
19+
]
20+
]
21+
, bgroup "aeson"
22+
[ bgroup "twitter"
23+
[ bench "100"
24+
(whnf (Aeson.decodeStrict' @Aeson.Value) byteStringTwitter100)
25+
]
26+
]
27+
]

0 commit comments

Comments
 (0)