2

I have a bunch of JSON strings, and would like to identify the schema of each one. This will allow me to keep a count of the different types of JSON objects in my collection of JSON strings.

I do not know the structure of these JSON strings ahead of time, and thus do not have a PONO to try to deserialize to.

I am currently using json.net, but am open to other options.

neverendingqs
  • 4,006
  • 3
  • 29
  • 57
  • Have you tried deserializing into a dynamic? You can deserialize into a dynamic and re-serialize that into a string as well. – Jerrod Horton Feb 02 '16 at 16:32
  • You have a common property in all but difrentes values ​​by type of json ? – 우두머리 Feb 02 '16 at 17:02
  • well, I know a way to generate it: not directly but.. you can convert the json file to c# class first: http://stackoverflow.com/questions/21611674/how-to-auto-generate-a-c-sharp-class-file-from-a-json-object-string and then convert the class into json schema: https://sixgun.wordpress.com/2012/02/09/using-json-net-to-generate-jsonschema/ Not the neatest solution but yeah it's possible. – Mc Kevin Feb 02 '16 at 17:15

2 Answers2

1

You could also use NJsonSchema for that, see https://github.com/RSuter/NJsonSchema/wiki/SampleJsonSchemaGenerator

Rico Suter
  • 11,548
  • 6
  • 67
  • 93
0

Previously JSchema was in JSON.NET Library but now its deprecated and they moved it to another library .. You Can Use Json.NET Schema ..It will easily Give You Schema of Any JSON String..even You Can Parse any JSON Using this Lib. ..like Suppose You Have JSON String ie _strJSON

JSchema schema = JSchema.Parse(_strJSON);
Alok
  • 342
  • 2
  • 8