{"id":26800512,"url":"https://github.com/ktsu-dev/njsonschemajsonconverter","last_synced_at":"2026-05-09T01:19:17.869Z","repository":{"id":270303409,"uuid":"909946956","full_name":"ktsu-dev/NJsonSchemaJsonConverter","owner":"ktsu-dev","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-14T01:50:27.000Z","size":235,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-14T08:51:24.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ktsu-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":"COPYRIGHT.md","agents":null,"dco":null,"cla":null}},"created_at":"2024-12-30T06:01:17.000Z","updated_at":"2026-02-14T01:49:46.000Z","dependencies_parsed_at":"2026-01-31T06:01:04.409Z","dependency_job_id":null,"html_url":"https://github.com/ktsu-dev/NJsonSchemaJsonConverter","commit_stats":null,"previous_names":["ktsu-dev/njsonschemajsonconverter"],"tags_count":46,"template":false,"template_full_name":null,"purl":"pkg:github/ktsu-dev/NJsonSchemaJsonConverter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FNJsonSchemaJsonConverter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FNJsonSchemaJsonConverter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FNJsonSchemaJsonConverter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FNJsonSchemaJsonConverter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ktsu-dev","download_url":"https://codeload.github.com/ktsu-dev/NJsonSchemaJsonConverter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FNJsonSchemaJsonConverter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29500821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T03:57:51.541Z","status":"ssl_error","status_checked_at":"2026-02-16T03:55:59.854Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-29T20:17:42.234Z","updated_at":"2026-02-16T05:03:51.157Z","avatar_url":"https://github.com/ktsu-dev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ktsu.NJsonSchemaJsonConverter\n\n\u003e A `JsonConverterFactory` for System.Text.Json that enables seamless serialization and deserialization of NJsonSchema `JsonSchema` objects.\n\n[![License](https://img.shields.io/github/license/ktsu-dev/NJsonSchemaJsonConverter)](https://github.com/ktsu-dev/NJsonSchemaJsonConverter/blob/main/LICENSE.md)\n[![NuGet](https://img.shields.io/nuget/v/ktsu.NJsonSchemaJsonConverter.svg)](https://www.nuget.org/packages/ktsu.NJsonSchemaJsonConverter/)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/ktsu.NJsonSchemaJsonConverter.svg)](https://www.nuget.org/packages/ktsu.NJsonSchemaJsonConverter/)\n[![Build Status](https://github.com/ktsu-dev/NJsonSchemaJsonConverter/workflows/build/badge.svg)](https://github.com/ktsu-dev/NJsonSchemaJsonConverter/actions)\n[![GitHub Stars](https://img.shields.io/github/stars/ktsu-dev/NJsonSchemaJsonConverter?style=social)](https://github.com/ktsu-dev/NJsonSchemaJsonConverter/stargazers)\n\n## Introduction\n\n`ktsu.NJsonSchemaJsonConverter` bridges the gap between [NJsonSchema](https://github.com/RicoSuter/NJsonSchema) and System.Text.Json. NJsonSchema provides its own JSON parsing and generation methods, but doesn't integrate natively with `System.Text.Json.Serialization`. This library provides a `JsonConverterFactory` that allows `JsonSchema` objects (and subclasses) to be serialized and deserialized as part of larger object graphs using `System.Text.Json.JsonSerializer`.\n\n## Features\n\n- **Full JsonSchema round-tripping** - Serialize and deserialize `JsonSchema` objects to/from JSON\n- **Subclass support** - Automatically handles any type derived from `JsonSchema`\n- **Drop-in integration** - Register as a converter in `JsonSerializerOptions` and it just works\n- **Lightweight** - Single source file, minimal dependencies\n\n## Installation\n\n### Package Manager Console\n\n```powershell\nInstall-Package ktsu.NJsonSchemaJsonConverter\n```\n\n### .NET CLI\n\n```bash\ndotnet add package ktsu.NJsonSchemaJsonConverter\n```\n\n### Package Reference\n\n```xml\n\u003cPackageReference Include=\"ktsu.NJsonSchemaJsonConverter\" Version=\"x.y.z\" /\u003e\n```\n\n## Usage Examples\n\n### Basic Setup\n\nRegister the converter factory in your `JsonSerializerOptions`:\n\n```csharp\nusing ktsu.NJsonSchemaJsonConverter;\nusing System.Text.Json;\n\nvar options = new JsonSerializerOptions\n{\n    Converters = { new NJsonSchemaJsonConverterFactory() }\n};\n```\n\n### Serializing an Object Containing a JsonSchema\n\n```csharp\nusing NJsonSchema;\nusing System.Text.Json;\n\npublic class SchemaContainer\n{\n    public string Name { get; set; } = string.Empty;\n    public JsonSchema? Schema { get; set; }\n}\n\n// Create a schema\nvar schema = await JsonSchema.FromTypeAsync\u003cMyModel\u003e();\n\nvar container = new SchemaContainer\n{\n    Name = \"MyModel Schema\",\n    Schema = schema\n};\n\n// Serialize - the schema is written as an inline JSON object\nstring json = JsonSerializer.Serialize(container, options);\n```\n\n### Deserializing an Object Containing a JsonSchema\n\n```csharp\n// Deserialize - the schema is parsed back into a JsonSchema object\nvar result = JsonSerializer.Deserialize\u003cSchemaContainer\u003e(json, options);\n\n// result.Schema is a fully functional JsonSchema instance\nConsole.WriteLine(result?.Schema?.Properties.Count);\n```\n\n### Using with Dependency Injection\n\n```csharp\nservices.AddSingleton(new JsonSerializerOptions\n{\n    Converters = { new NJsonSchemaJsonConverterFactory() }\n});\n```\n\n## How It Works\n\nThe converter handles `JsonSchema` serialization in two directions:\n\n- **Writing**: Calls `JsonSchema.ToJson()` to produce the schema's JSON representation and writes it inline using `WriteRawValue`\n- **Reading**: Reads the JSON token as a string and parses it using `JsonSchema.FromJsonAsync()` to reconstruct the schema object\n\nThe factory uses reflection to create type-specific generic converter instances, supporting `JsonSchema` and any subclass.\n\n## API Reference\n\n### `NJsonSchemaJsonConverterFactory`\n\nA `JsonConverterFactory` that creates converters for `JsonSchema` and its subclasses.\n\n| Method                                          | Description                                                        |\n|-------------------------------------------------|--------------------------------------------------------------------|\n| `CanConvert(Type)`                              | Returns `true` for `JsonSchema` and any type deriving from it      |\n| `CreateConverter(Type, JsonSerializerOptions)`  | Creates a type-specific `JsonConverter\u003cT\u003e` instance via reflection |\n\n## Contributing\n\nContributions are welcome! Here's how you can help:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\nPlease make sure to update tests as appropriate.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsu-dev%2Fnjsonschemajsonconverter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fktsu-dev%2Fnjsonschemajsonconverter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsu-dev%2Fnjsonschemajsonconverter/lists"}