Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nouemankhal/go-json-parser

Go solution for the Build Your Own JSON Parser Coding Challenge by John Crickett
https://github.com/nouemankhal/go-json-parser

go json lexer parser

Last synced: 1 day ago
JSON representation

Go solution for the Build Your Own JSON Parser Coding Challenge by John Crickett

Awesome Lists containing this project

README

        

# Coding Challenge #2: Build Your Own JSON Parser

This is my solution to the second problem in the [John Crickett's Coding Challenges](https://codingchallenges.fyi/challenges/challenge-json-parser/).

I made this project just for fun and to play around with lexers and parsers, it is still a work in progress.

## Setup

1. Clone the repo
1. Run the tool using of the following approaches:

```shell
# Run the tool automatically using the go command
$ go run . [file] [path]

# Build a binary and run it manually
$ go build -o gojson
$ ./gojson [file] [path]

# Install the binary in your environment, and run it:
$ go install
$ gojson [file] [path]
```
1. Done!

## Usage
```shell
Usage:
gojson [FILE] [PATH]

Example:
gojson tests/step1/valid.json .key
cat file.json | gojson .foo.bar[0]
```

## Examples

```shell
$ gojson tests/step4/valid2.json .key-o
{"inner key": "inner value"}

$ gojson tests/step4/valid.json .key
"value"

$ gojson tests/step3/invalid.json
cannot parse value, got token 'False' at line 3:9
exit status 1
```