RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.38k stars 532 forks source link

Giving wrong json schema for sample json #1609

Open anaparthi-k opened 1 year ago

anaparthi-k commented 1 year ago

Sample Json:

[{ "created_at": "Thu Jun 22 21:00:00 +0000 2017", "id": 877994604561387500, "id_str": "877994604561387520", "text": "Creating a Grocery List Manager Using Angular, Part 1: Add & Display Items https://t.co/xFox78juL1 #Angular", "truncated": false, "entities": { "hashtags": [{ "text": "Angular", "indices": [103, 111] }], "symbols": [1], "user_mentions": [2], "urls": [{ "url": "https://t.co/xFox78juL1", "expanded_url": "http://buff.ly/2sr60pf", "display_url": "buff.ly/2sr60pf", "indices": [79, 102] }] }, "source": "<a href=\"http://bufferapp.com\" rel=\"nofollow\">Buffer", "user": { "id": 772682964, "id_str": "772682964", "name": "SitePoint JavaScript", "screen_name": "SitePointJS", "location": "Melbourne, Australia", "description": "Keep up with JavaScript tutorials, tips, tricks and articles at SitePoint.", "url": "http://t.co/cCH13gqeUK", "entities": { "url": { "urls": [{ "url": "http://t.co/cCH13gqeUK", "expanded_url": "https://www.sitepoint.com/javascript", "display_url": "sitepoint.com/javascript", "indices": [0, 22] }] }, "description": { "urls": ["http://t.co/cCH13gqeUK"] } }, "protected": false, "followers_count": 2145, "friends_count": 18, "listed_count": 328, "created_at": "Wed Aug 22 02:06:33 +0000 2012", "favourites_count": 57, "utc_offset": 43200, "time_zone": "Wellington", }, }]

"output scheme json"

{{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "array", "items": { "$ref": "#/definitions/Anonymous" }, "definitions": { "Entities": { "type": "object", "properties": { "hashtags": { "type": "array", "items": { "$ref": "#/definitions/Hashtag" } }, "symbols": { "type": "array", "items": { "$ref": "#/definitions/Symbol" } }, "user_mentions": { "type": "array", "items": { "$ref": "#/definitions/User_mention" } }, "urls": { "type": "array", "items": { "$ref": "#/definitions/Anonymous11" } } } }, "Indice": { "type": "integer" }, "Hashtag": { "type": "object", "properties": { "text": { "type": "string" }, "indices": { "type": "array", "items": { "$ref": "#/definitions/Indice" } } } }, "Symbol": { "type": "integer" }, "User_mention": { "type": "integer" }, "Anonymous6": { "type": "integer" }, "Url": { "type": "object", "properties": { "url": { "type": "string" }, "expanded_url": { "type": "string" }, "display_url": { "type": "string" }, "indices": { "type": "array", "items": { "$ref": "#/definitions/Anonymous6" } } } }, "User": { "type": "object", "properties": { "id": { "type": "integer" }, "id_str": { "type": "string" }, "name": { "type": "string" }, "screen_name": { "type": "string" }, "location": { "type": "string" }, "description": { "$ref": "#/definitions/Entities" }, "url": { "$ref": "#/definitions/Entities" }, "entities": { "$ref": "#/definitions/User" }, "protected": { "type": "boolean" }, "followers_count": { "type": "integer" }, "friends_count": { "type": "integer" }, "listed_count": { "type": "integer" }, "created_at": { "type": "string" }, "favourites_count": { "type": "integer" }, "utc_offset": { "type": "integer" }, "time_zone": { "type": "string" } } }, "Anonymous9": { "type": "integer" }, "Anonymous10": { "type": "object", "properties": { "url": { "type": "string" }, "expanded_url": { "type": "string" }, "display_url": { "type": "string" }, "indices": { "type": "array", "items": { "$ref": "#/definitions/Anonymous9" } } } }, "Anonymous11": { "type": "string" }, "Anonymous": { "type": "object", "properties": { "created_at": { "type": "string" }, "id": { "type": "integer" }, "id_str": { "type": "string" }, "text": { "type": "string" }, "truncated": { "type": "boolean" }, "entities": { "$ref": "#/definitions/Entities" }, "source": { "type": "string" }, "user": { "$ref": "#/definitions/User" } } } } }}

Usage example: JsonSchema.FromSampleJson(content).ToJson()