Giter VIP home page Giter VIP logo

snakeyaml's Introduction

The art of simplicity is a puzzle of complexity.

Overview

YAML is a data serialization format designed for human readability and interaction with scripting languages.

SnakeYAML is a YAML processor for the Java Virtual Machine.

SnakeYAML features

  • a complete YAML 1.1 processor. In particular, SnakeYAML can parse all examples from the specification.
  • Unicode support including UTF-8/UTF-16 input/output.
  • high-level API for serializing and deserializing native Java objects.
  • support for all types from the YAML types repository.
  • relatively sensible error messages.

Info

Contribute

snakeyaml's People

Contributors

asomov avatar jordanangold avatar maslovalex avatar obfischer avatar oscarscholten avatar rbuckland avatar rokish avatar schulzh avatar slachiewicz avatar splatch avatar tareksha avatar

Watchers

 avatar  avatar

Forkers

doxiao

snakeyaml's Issues

checkDelegates() in TypeDescription causes it to search for the property I'm trying to substitute

Hello,

I have a property that contains a hyphen, and I want to map it to a field in the class with camel case.

I added following TypeDescriptor to the constructor:

           Constructor constructor = new Constructor(ApplicationProperties.class);
           TypeDescription flywayDesc = new TypeDescription(ApplicationProperties.Flyway.class);
            flywayDesc.substituteProperty("default-schema", ApplicationProperties.Flyway.class,
                "getDefaultSchema", "setDefaultSchema");
            flywayDesc.setExcludes("defaultSchema");
            constructor.addTypeDescription(flywayDesc);

and passed it to the Yaml class in the constructor:

            Yaml yamlLoader = new Yaml(constructor);

The ApplicationProperties class looks as follows:

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ApplicationProperties {

  private Spring spring;

  @Data
  public static class Flyway {

    private String schemas;
    private String defaultSchema;
  }

  @Data
  public static class Spring {

    private Flyway flyway;
  }

}

And an example of the file is:

spring:
  flyway:
    schemas: schema1, schema2
    default-schema: schema1

However, the code fails on reading the default-schema property because of the checkDelegatesmethod in TypeDescriptor which calls discoverProperty for all properties in the class. This method does a getProperty without checking the TypeDescriptor itself for that property, which is done in the Constructor class:

                    TypeDescription memberDescription = typeDefinitions.get(beanType);
                    Property property = memberDescription == null ? getProperty(beanType, key)
                            : memberDescription.getProperty(key);

Deserializing problem

Hi,

I am deserializing a class, saving it to file and right after it I am loading and serializing it, but it outputs an error and I can't understand why. The code is available on GitHub https://github.com/SuperMarcomen/SuperLib.
Here is the error: https://pastebin.com/3s3RRbpZ

Even tough there is an error during the serialization, the deserialization works fine, but I would like to change the output a bit, but I can't understand how to do it.

!!it.marcodemartino.superlib.Config
location: {serializedLocation: 'world:0.0:0.0:0.0:0.0:0.0'}
pirla: test

As you can see, SnakeYaml saves the instance of SerializableLocation with the name "location" and then it saves its field "serializedLocation", but I would like have just a string called "location" as output.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.