Skip to content

Commit 12cec31

Browse files
committed
Add README; copyright
1 parent 1dd2174 commit 12cec31

21 files changed

Lines changed: 100 additions & 0 deletions

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# jsonata-cpp
2+
3+
[![Build Status][github-actions-shield]][github-actions-link]
4+
5+
[github-actions-shield]: https://github.com/rayokota/jsonata-cpp/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=master
6+
7+
C++ implementation of JSONata.
8+
9+
This is a C++ port of the [JSONata reference implementation](https://github.com/jsonata-js/jsonata),
10+
and also borrows from the [Dashjoin Java port](https://github.com/dashjoin/jsonata-java).
11+
12+
This implementation supports 100% of the language features of JSONata, using [nlohmann_json](https://github.com/nlohmann/json).
13+
The JSONata documentation can be found [here](https://jsonata.org).
14+
15+
16+
## Installation
17+
18+
Installation uses CMake as follows:
19+
20+
```
21+
include(FetchContent)
22+
23+
FetchContent_Declare(
24+
jsonata
25+
URL https://github.com/rayokota/jsonata-cpp/archive/refs/tags/v0.1.0.zip
26+
URL_HASH SHA256=3ee1798f28a29d36ebbb273853979926716a384e4d491a6bd408e1f6de51760d # Optional
27+
)
28+
FetchContent_MakeAvailable(jsonata)
29+
30+
# Use the library
31+
target_link_libraries(your_target jsonata::jsonata)
32+
```
33+
34+
## Getting Started
35+
36+
A very simple start:
37+
38+
```
39+
#include <iostream>
40+
#include <jsonata/Jsonata.h>
41+
#include <nlohmann/json.hpp>
42+
43+
int main() {
44+
// Create the data equivalent to Python
45+
auto data = nlohmann::ordered_json::parse(R"({
46+
"example": [
47+
{"value": 4},
48+
{"value": 7},
49+
{"value": 13}
50+
]
51+
})");
52+
53+
// Create the JSONata expression
54+
jsonata::Jsonata expr("$sum(example.value)");
55+
56+
// Evaluate the expression with the data
57+
auto result = expr.evaluate(data);
58+
59+
// Print the result
60+
std::cout << "Result: " << result << std::endl;
61+
62+
return 0;
63+
}
64+
```
65+
66+
## Running Tests
67+
68+
This project uses the repository of the reference implementation as a submodule. This allows referencing the current version of the unit tests. To clone this repository, run:
69+
70+
```
71+
git clone --recurse-submodules https://github.com/rayokota/jsonata-cpp
72+
```
73+
74+
To build and run the unit tests:
75+
76+
```
77+
cmake -DJSONATA_BUILD_TESTS=ON -S . -B build
78+
cmake --build build
79+
cd build && ctest
80+
```

include/jsonata/Functions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* jsonata-cpp is the JSONata C++ reference port
33
*
44
* Copyright Dashjoin GmbH. https://dashjoin.com
5+
* Copyright Robert Yokota
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
78
* you may not use this file except in compliance with the License.

include/jsonata/JException.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* jsonata-cpp is the JSONata C++ reference port
33
*
44
* Copyright Dashjoin GmbH. https://dashjoin.com
5+
* Copyright Robert Yokota
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
78
* you may not use this file except in compliance with the License.

include/jsonata/Jsonata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* jsonata-cpp is the JSONata C++ reference port
33
*
44
* Copyright Dashjoin GmbH. https://dashjoin.com
5+
* Copyright Robert Yokota
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
78
* you may not use this file except in compliance with the License.

include/jsonata/Parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* jsonata-cpp is the JSONata C++ reference port
33
*
44
* Copyright Dashjoin GmbH. https://dashjoin.com
5+
* Copyright Robert Yokota
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
78
* you may not use this file except in compliance with the License.

include/jsonata/Timebox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* jsonata-cpp is the JSONata C++ reference port
33
*
44
* Copyright Dashjoin GmbH. https://dashjoin.com
5+
* Copyright Robert Yokota
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
78
* you may not use this file except in compliance with the License.

include/jsonata/Tokenizer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* jsonata-cpp is the JSONata C++ reference port
33
*
44
* Copyright Dashjoin GmbH. https://dashjoin.com
5+
* Copyright Robert Yokota
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
78
* you may not use this file except in compliance with the License.

include/jsonata/Utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* jsonata-cpp is the JSONata C++ reference port
33
*
44
* Copyright Dashjoin GmbH. https://dashjoin.com
5+
* Copyright Robert Yokota
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
78
* you may not use this file except in compliance with the License.

include/jsonata/utils/Constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* jsonata-cpp is the JSONata C++ reference port
33
*
44
* Copyright Dashjoin GmbH. https://dashjoin.com
5+
* Copyright Robert Yokota
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
78
* you may not use this file except in compliance with the License.

include/jsonata/utils/DateTimeUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* jsonata-cpp is the JSONata C++ reference port
33
*
44
* Copyright Dashjoin GmbH. https://dashjoin.com
5+
* Copyright Robert Yokota
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
78
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)