Giter Site home page Giter Site logo

nryaml's Introduction

nryaml

This small library aims to make it easier to work with data returned from a yaml parser such as snakeyaml. The design is influence from the antonsjava/json parsing library and the types it returns.

The basic idea is that in Java, navigating a structure built by arbitrary primitive types, maps and lists is verbose and error-prone. One needs to cast the data to be able to traverse it, and little library offers a convenient way chaining method calls instead.

License

This code is licensed under the Apache License version 2.0, please see LICENSE for additional details.

nryaml's People

Contributors

nresare avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

alfredomusumeci

nryaml's Issues

NullPointerException when parsing values set to null

Hello,

A NullPointerException is thrown whenever a null value is present in a YAML file, more specifically: Exception in thread "main" java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "input" is null.

The following is a simple case to reproduce the error:

apiVersion: dummyApi
kind: CustomResourceDefinition
metadata:
  name: null

If I then use the function allFromPath to parse the above YAML file, the error is thrown.

The proposed solution has to do with the method handling the parsing itself, more specifically:

    public static Iterable<YAMLValue> allFromPath(Path path) {
        try (var inputStream = Files.newInputStream(path)) {
            return stream(parser.get().loadAll(inputStream))
                    .map(YAMLValueImpl::new)
                    .collect(Collectors.toList());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

I suppose the error arises from the line YAMLValueImpl:new.

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.