https://github.com/dmjio/json-test
JSON parser written with Happy / Alex
https://github.com/dmjio/json-test
alex happy haskell json parser-generator
Last synced: 3 months ago
JSON representation
JSON parser written with Happy / Alex
- Host: GitHub
- URL: https://github.com/dmjio/json-test
- Owner: dmjio
- License: bsd-3-clause
- Created: 2018-10-08T03:58:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-12-14T01:07:09.000Z (over 1 year ago)
- Last Synced: 2025-01-16T14:32:26.078Z (over 1 year ago)
- Topics: alex, happy, haskell, json, parser-generator
- Language: Haskell
- Homepage: https://tools.ietf.org/html/rfc7159.html
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
json-test
==================
A specification abiding implementation of [JSON](https://www.json.org/) [RFC-7159](https://tools.ietf.org/html/rfc7159)
using [alex](https://www.haskell.org/alex/) and [happy](https://www.haskell.org/happy/).
### Usage
Given an example `JSON` file.
```json
{ "foo" : [{"bar": [1,2,true,false, {}]}], "baz": { "woz" : [] } }
```
The following code will parse the above into `aeson`'s `Value` type (via `alex` and `happy`).
```haskell
module Main (main) where
import JSON.Parser (parse)
parseWithJSONTest :: IO ()
parseWithJSONTest =
print =<< parse <$> readFile fileName
```
to yield
```haskell
Right (Object (fromList [
("foo", Array [Object (fromList [
("bar",Array [Number 1.0,Number 2.0,Bool True,Bool False,Object (fromList [])])])])
,("baz",Object (fromList [("woz",Array [])
]))
]))
```
### Build
```bash
nix-build
```
### Develop
```bash
nix-shell
```
### Benchmark
```bash
nix-build && ./result/bin/example -o index.html && open index.html
```