Jaahas.Json.TimeSeriesExtractor
4.0.0
dotnet add package Jaahas.Json.TimeSeriesExtractor --version 4.0.0
NuGet\Install-Package Jaahas.Json.TimeSeriesExtractor -Version 4.0.0
<PackageReference Include="Jaahas.Json.TimeSeriesExtractor" Version="4.0.0" />
<PackageVersion Include="Jaahas.Json.TimeSeriesExtractor" Version="4.0.0" />
<PackageReference Include="Jaahas.Json.TimeSeriesExtractor" />
paket add Jaahas.Json.TimeSeriesExtractor --version 4.0.0
#r "nuget: Jaahas.Json.TimeSeriesExtractor, 4.0.0"
#:package Jaahas.Json.TimeSeriesExtractor@4.0.0
#addin nuget:?package=Jaahas.Json.TimeSeriesExtractor&version=4.0.0
#tool nuget:?package=Jaahas.Json.TimeSeriesExtractor&version=4.0.0
About
Jaahas.Json.TimeSeriesExtractor is a library for extracting time series data from JSON documents using System.Text.Json. Its primary use case is separating structured JSON payloads from IoT and IIoT devices into separate time series for storage in a database or other time series data store.
More documentation is available on GitHub.
How to Use
Use the static TimeSeriesExtractor.GetSamples method to extract values from a JSON string or a JsonElement and return them as a collection of TimeSeriesSample objects:
const string json = @"{ ""timestamp"": ""2021-05-30T09:47:38Z"", ""temperature"": 24.7, ""pressure"": 1021.3, ""humidity"": 33.76 }";
var samples = TimeSeriesExtractor.GetSamples(json);
You can customise the extraction behaviour by providing a TimeSeriesExtractorOptions object when calling TimeSeriesExtractor.GetSamples:
// data.json
{
"data": [
{
"src": "Instrument-1",
"ts": "2024-04-13T10:01:47Z",
"val": 1019
},
{
"src": "Instrument-2",
"ts": "2024-04-13T09:59:51Z",
"val": 23.7
},
{
"src": "Instrument-2",
"ts": "2024-04-13T10:00:32Z",
"val": 23.6
}
]
}
var jsonOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
jsonOptions.Converters.Add(new JsonStringEnumConverter());
JsonElement json;
using (var stream = new FileStream("data.json", FileMode.Open)) {
json = await JsonSerializer.DeserializeAsync<JsonElement>(stream, jsonOptions);
}
var options = new TimeSeriesExtractorOptions() {
// We want to extract samples from nested objects.
Recursive = true,
// The "data" property in our JSON document contains an array of samples, each with its own
// timestamp.
AllowNestedTimestamps = true,
// The timestamp is located at the "ts" property on each sample object.
TimestampProperty = "/ts",
// Each object in the samples array contains a "val" property with the sample value. We'll use
// an MQTT-style match expression to only extract values from the "val" property on each
// object in the samples array.
CanProcessElement = TimeSeriesExtractor.CreateJsonPointerMatchDelegate(new JsonPointerMatchDelegateOptions() {
PointersToInclude = ["/data/+/val"],
AllowWildcardExpressions = true
}),
// Each object in the samples array contains a "src" property with the name of the instrument
// for the sample. We'll use this as the key when emitting a sample instead of inferring a key.
Template = "{src}"
};
foreach (var sample in TimeSeriesExtractor.GetSamples(json, options)) {
Console.WriteLine(JsonSerializer.Serialize(sample, jsonOptions));
}
// Output:
// {"key":"Instrument-1","timestamp":"2024-04-13T10:01:47Z","value":1019,"timestampSource":"Document"}
// {"key":"Instrument-2","timestamp":"2024-04-13T09:59:51Z","value":23.7,"timestampSource":"Document"}
// {"key":"Instrument-2","timestamp":"2024-04-13T10:00:32Z","value":23.6,"timestampSource":"Document"}
Please refer to the documentation for more information.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- JsonPointer.Net (>= 7.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
- System.Text.Json (>= 10.0.2)
-
net10.0
- JsonPointer.Net (>= 7.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
-
net8.0
- JsonPointer.Net (>= 7.0.0)
- System.Text.Json (>= 10.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0 | 78 | 2/6/2026 |
| 3.0.3 | 241 | 8/9/2025 |
| 3.0.1 | 317 | 7/20/2025 |
| 3.0.0 | 166 | 7/12/2025 |
| 2.0.1 | 203 | 7/11/2025 |
| 2.0.0 | 466 | 3/3/2025 |
| 1.0.0 | 262 | 10/11/2024 |
| 1.0.0-preview7 | 135 | 5/12/2024 |
| 1.0.0-preview5 | 189 | 4/16/2024 |
| 1.0.0-preview4 | 161 | 4/15/2024 |
| 1.0.0-preview3.0 | 116 | 4/13/2024 |
| 1.0.0-preview2.0 | 133 | 4/13/2024 |
| 1.0.0-preview1.0 | 103 | 4/12/2024 |
| 0.14.0 | 258 | 4/6/2024 |
| 0.13.0 | 231 | 4/5/2024 |
| 0.12.1 | 342 | 12/14/2023 |
| 0.12.0 | 240 | 12/14/2023 |
| 0.11.0 | 251 | 12/11/2023 |
| 0.10.0 | 304 | 6/12/2023 |