Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jplane/coeus
JQ-style queries for JSON.NET in any .NET Core process.
https://github.com/jplane/coeus
Last synced: 20 days ago
JSON representation
JQ-style queries for JSON.NET in any .NET Core process.
- Host: GitHub
- URL: https://github.com/jplane/coeus
- Owner: jplane
- License: mit
- Created: 2021-03-05T16:50:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-16T13:02:55.000Z (almost 3 years ago)
- Last Synced: 2024-04-28T05:53:58.802Z (6 months ago)
- Language: C#
- Size: 26.4 KB
- Stars: 12
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Coeus - JQ-compatible JSON Queries in .NET
| | |
| --- | --- |
| Coeus NUGET Package | [![NuGet](https://img.shields.io/nuget/v/Coeus)](https://www.nuget.org/packages/Coeus/) |
| | |Simply put, Coeus implements [JQ](https://stedolan.github.io/jq/)-compatible queries for [JSON.NET](https://www.newtonsoft.com/json). Query and update JToken, JObject, JArray, JValue and friends.
JQ is more powerful than JSON Path/Patch and is a widely-adopted pseudo-standard from the Linux command line.
## Goals
- Simple extension methods for System.String to query against JToken
- No CLI (yet)
- 100% JQ compatibility may not be realistic, though we'll strive to include most operators and functions
## Usage
```csharp
var json = new JObject
{
["foo"] = new JArray { 1, 2, 3 }
};var query = "{ \"bar\": .foo[2] }";
var output = query.EvalToToken(json);
// output --> { 'bar': 3 }
Console.WriteLine(output["bar"].Value()); // 3
```
## Background and Resources
- The JQ [manual](https://stedolan.github.io/jq/manual/) is a wealth of information about query syntax and behavior
- Coeus is implemented using the excellent [Sprache](https://github.com/sprache/Sprache) parser combinator library
- More on parser combinators [here](https://en.wikipedia.org/wiki/Parser_combinator). Your head will hurt, until it doesn't :-)