private static string Zip(JsonSchema jsonSchema) { JsonSerializer serializer = new JsonSerializer(); JsonValue json = serializer.Serialize(jsonSchema); byte[] bytes = Encoding.UTF8.GetBytes(json.GetIndentedString()); using (MemoryStream msi = new MemoryStream(bytes)) using (MemoryStream mso = new MemoryStream()) { using (GZipStream gs = new GZipStream(mso, CompressionMode.Compress)) { msi.CopyTo(gs); } return(Convert.ToBase64String(mso.ToArray())); } }
public static string ValidateSchema(string jsonText, string schemaText) { var serializer = new Manatee.Json.Serialization.JsonSerializer(); var json = Manatee.Json.JsonValue.Parse(jsonText); var schemaJson = Manatee.Json.JsonValue.Parse(schemaText); var schema = new Manatee.Json.Schema.JsonSchema(); schema.FromJson(schemaJson, serializer); Manatee.Json.Schema.JsonSchemaOptions.OutputFormat = Manatee.Json.Schema.SchemaValidationOutputFormat.Basic; var validationResults = schema.ValidateSchema(); if (!validationResults.IsValid) { json = serializer.Serialize(validationResults); return(JsonHelper.FormatJson(json.ToString())); } else { return(""); } }