Skip to content

Commit c22b372

Browse files
Initial code import (#1)
* initial code import * Remove note-go dependency * Update README.md Co-authored-by: Stefan VanBuren <[email protected]> * add missing link to code of conduct * update contributing info to readme * Fix staticcheck errors Co-authored-by: Stefan VanBuren <[email protected]>
1 parent 51fc2ae commit c22b372

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+34784
-2
lines changed

CODE_OF_CONDUCT.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Code of conduct
2+
3+
By participating in this project, you agree to abide by the
4+
[Blues Inc code of conduct][1].
5+
6+
[1]: https://blues.github.io/opensource/code-of-conduct
7+

CONTRIBUTING.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Contributing to blues/jsonata-go
2+
3+
We love pull requests from everyone. By participating in this project, you
4+
agree to abide by the Blues Inc [code of conduct].
5+
6+
[code of conduct]: https://blues.github.io/opensource/code-of-conduct
7+
8+
Here are some ways *you* can contribute:
9+
10+
* by using alpha, beta, and prerelease versions
11+
* by reporting bugs
12+
* by suggesting new features
13+
* by writing or editing documentation
14+
* by writing specifications
15+
* by writing code ( **no patch is too small** : fix typos, add comments,
16+
clean up inconsistent whitespace )
17+
* by refactoring code
18+
* by closing [issues][]
19+
* by reviewing patches
20+
21+
[issues]: https://github.com/blues/jsonata-go/issues
22+
23+
## Submitting an Issue
24+
25+
* We use the [GitHub issue tracker][issues] to track bugs and features.
26+
* Before submitting a bug report or feature request, check to make sure it
27+
hasn't
28+
already been submitted.
29+
* When submitting a bug report, please include a [Gist][] that includes a stack
30+
trace and any details that may be necessary to reproduce the bug, including
31+
your release version, stack, and operating system. Ideally, a bug report
32+
should include a pull request with failing specs.
33+
34+
[gist]: https://gist.github.com/
35+
36+
## Cleaning up issues
37+
38+
* Issues that have no response from the submitter will be closed after 30 days.
39+
* Issues will be closed once they're assumed to be fixed or answered. If the
40+
maintainer is wrong, it can be opened again.
41+
* If your issue is closed by mistake, please understand and explain the issue.
42+
We will happily reopen the issue.
43+
44+
## Submitting a Pull Request
45+
46+
1. [Fork][fork] the [official repository][repo].
47+
2. [Create a topic branch.][branch]
48+
3. Implement your feature or bug fix.
49+
4. Add, commit, and push your changes.
50+
5. [Submit a pull request.][pr]
51+
52+
## Notes
53+
54+
* Please add tests if you changed code. Contributions without tests won't be accepted.
55+
* If you don't know how to add tests, please put in a PR and leave a comment asking for help.
56+
We love helping!
57+
58+
[repo]: https://github.com/blues/jsonata-go/tree/master
59+
[fork]: https://help.github.com/articles/fork-a-repo/
60+
[branch]:
61+
https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
62+
[pr]: https://help.github.com/articles/creating-a-pull-request-from-a-fork/
63+
64+
Inspired by
65+
https://github.com/thoughtbot/factory_bot/blob/master/CONTRIBUTING.md
66+

README.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,79 @@
1-
# jsonata-go
2-
Open Source Go version of JSONata
1+
# JSONata in Go
2+
3+
Package jsonata is a query and transformation language for JSON.
4+
It's a Go port of the JavaScript library [JSONata](http://jsonata.org/).
5+
6+
It currently has feature parity with jsonata-js 1.5.4. As well as a most of the functions added in newer versions. You can see potentially missing functions by looking at the [jsonata-js changelog](https://github.com/jsonata-js/jsonata/blob/master/CHANGELOG.md).
7+
8+
## Install
9+
10+
go get github.com/blues/jsonata-go
11+
12+
## Usage
13+
14+
```Go
15+
import (
16+
"encoding/json"
17+
"fmt"
18+
"log"
19+
20+
jsonata "github.com/blues/jsonata-go"
21+
)
22+
23+
const jsonString = `
24+
{
25+
"orders": [
26+
{"price": 10, "quantity": 3},
27+
{"price": 0.5, "quantity": 10},
28+
{"price": 100, "quantity": 1}
29+
]
30+
}
31+
`
32+
33+
func main() {
34+
35+
var data interface{}
36+
37+
// Decode JSON.
38+
err := json.Unmarshal([]byte(jsonString), &data)
39+
if err != nil {
40+
log.Fatal(err)
41+
}
42+
43+
// Create expression.
44+
e := jsonata.MustCompile("$sum(orders.(price*quantity))")
45+
46+
// Evaluate.
47+
res, err := e.Eval(data)
48+
if err != nil {
49+
log.Fatal(err)
50+
}
51+
52+
fmt.Println(res)
53+
// Output: 135
54+
}
55+
```
56+
57+
## JSONata Server
58+
A locally hosted version of [JSONata Exerciser](http://try.jsonata.org/)
59+
for testing is [available here](https://github.com/blues/jsonata-go/jsonata-server).
60+
61+
## JSONata tests
62+
A CLI tool for running jsonata-go against the [JSONata test suite](https://github.com/jsonata-js/jsonata/tree/master/test/test-suite) is [available here](https://github.com/blues/jsonata-go/jsonata-test).
63+
64+
65+
66+
## Contributing
67+
68+
We love issues, fixes, and pull requests from everyone. Please run the
69+
unit-tests, staticcheck, and goimports prior to submitting your PR. By participating in this project, you agree to abide by
70+
the Blues Inc [code of conduct](https://blues.github.io/opensource/code-of-conduct).
71+
72+
For details on contributions we accept and the process for contributing, see our
73+
[contribution guide](CONTRIBUTING.md).
74+
75+
In addition to the Go unit tests there is also a test runner that will run against the jsonata-js test
76+
suite in the [jsonata-test](https://github.com/blues/jsonata-go/jsonata-test) directory. A number of these tests currently fail, but we're working towards feature parity with the jsonata-js reference implementation. Pull requests welcome!
77+
78+
If you would like to contribute to this library a good first issue would be to run the jsonata-test suite,
79+
and fix any of the tests not passing.

0 commit comments

Comments
 (0)