示例#1
0
        static void Main(string[] args)
        {
            // {"@context":"https://schema.org","@type":"CustomType","Name":"Hello World"}
            var inputObj = new CustomType
            {
                Name = "Hello World"
            };

            var json = SchemaSerializer.SerializeObject(inputObj);

            var outputObj = SchemaSerializer.DeserializeObject <CustomType>(json);
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine(args[0]);

            using (FileStream zipToOpen = new FileStream(@args[0], FileMode.Open))
            {
                var recipes = RecipeKeeperImporter.GetSchemaRecipes(zipToOpen);

                string recipesJsonStr = SchemaSerializer.SerializeObject(recipes);

                // FIXME: line andings are currently not write correct to file
                // correct the line endings for host OS
                //recipesJsonStr = Regex.Replace(recipesJsonStr, @"\\r\\n?|\\n", Environment.NewLine);

                File.WriteAllText("recipes.json", recipesJsonStr, Encoding.UTF8);
                Console.WriteLine(recipesJsonStr);
            }

            Console.WriteLine("Import completed!");
        }
 private static string SerializeObject <T>(T value)
     where T : IValues
 => SchemaSerializer.SerializeObject(new TestModel <T> {
     Property = value
 });