Exemple #1
0
        public JkumWriter()
        {
            this.jkum          = new Jkum();
            this.jkum.Manholes = new List <Manhole>();

            serializerSettings            = new JsonSerializerSettings();
            serializerSettings.Formatting = Formatting.Indented;
        }
Exemple #2
0
        public Jkum ReadFile(string fileToRead)
        {
            string jsonString = File.ReadAllText(fileToRead);

            JsonTextReader reader      = new JsonTextReader(new StringReader(jsonString));
            string         readContent = reader.ToString();

            JSchemaValidatingReader validatingReader = new JSchemaValidatingReader(reader);
            string currentFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string schemaFile    = Path.Combine(currentFolder, "Schema", "jkum-schema-1.0.json");
            string jsonSchema    = File.ReadAllText(schemaFile);

            validatingReader.Schema = JSchema.Parse(jsonSchema, new JSchemaReaderSettings());

            JsonSerializer serializer = new JsonSerializer();
            Jkum           jkum       = serializer.Deserialize <Jkum>(validatingReader);

            return(jkum);
        }