Coder Social home page Coder Social logo

Support for "<<: reference" about yaml-rust HOT 9 OPEN

chyh1990 avatar chyh1990 commented on September 26, 2024 5
Support for "<<: reference"

from yaml-rust.

Comments (9)

sinesc avatar sinesc commented on September 26, 2024 4

@mathstuf I don't think it was questioned whether it works. The relevant function merge_keys_serde simply does not show up in the documentation on docs.rs (feature not enabled), so one has to find it in the source code of your library.

Since this issue comes up in a google search, here's a minimal example:

let value = serde_yaml::from_str(&input_yaml_string).unwrap(); // Value
let merged = yaml_merge_keys::merge_keys_serde(value).unwrap(); // merged Value
let typed_value: T = serde_yaml::from_value(merged).unwrap(); // merged T

from yaml-rust.

mathstuf avatar mathstuf commented on September 26, 2024 1

I've just published 0.2.1.

from yaml-rust.

alyssais avatar alyssais commented on September 26, 2024

FWIW I also needed this and came across https://gitlab.kitware.com/utils/rust-yaml-merge-keys, which adds support for << on top on this library.

Would still love it if it could be supported by yaml-rust by default, though!

from yaml-rust.

JordiPolo avatar JordiPolo commented on September 26, 2024

Thanks for the pointer. I've tried to make it work (I'm using serde-yaml) but it seems I'm not able to.
Support here would be ideal as it would just work™

from yaml-rust.

mathstuf avatar mathstuf commented on September 26, 2024

yaml-merge-keys developer here. It supports serde-yaml using the serde_yaml feature. We use it in our code just fine.

from yaml-rust.

mathstuf avatar mathstuf commented on September 26, 2024

I looked into it and it now seems possible to specify features for documentation builds. I'll do that for the crate.

from yaml-rust.

mathstuf avatar mathstuf commented on September 26, 2024

Ah, I had done so, but hadn't made a release since then.

from yaml-rust.

tmccombs avatar tmccombs commented on September 26, 2024

There is a spec for this, althouth it is not part of 1.2 itself: https://yaml.org/type/merge.html

from yaml-rust.

mathstuf avatar mathstuf commented on September 26, 2024

I've seen multiple parsers get very loose around the merge key spec. Apparently this is valid for the Ruby parser:

foo:
  <<: *bar
  <<: *baz

(given anchors named bar and baz) but seems like…quite cavalier YAML without the supplemental spec. If you want to apply the merge keys spec, my crate handles that for you and it works with plain yaml-rust and serde_yaml. Other YAML libraries can be considered (through feature flags).

from yaml-rust.

Related Issues (20)

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.