GithubHelp home page GithubHelp logo

Comments (10)

perlpunk avatar perlpunk commented on June 6, 2024 1

whoops, that's right.
It's because I don't actually add existing data to a given hash/array when tieing it.

I prepared a fix under:
https://github.com/perlpunk/YAML-PP-p5/tree/fix-preserve

from yaml-pp-p5.

perlpunk avatar perlpunk commented on June 6, 2024

Yes, that sounds like it makes sense and shouldn't be to difficult to implement.
Meanwhile, you can manually create ordered hashes with YAML:PP->preserved_hash

from yaml-pp-p5.

perlpunk avatar perlpunk commented on June 6, 2024

OTOH what do we do in arrays that are inside a preserved hash?

from yaml-pp-p5.

perlpunk avatar perlpunk commented on June 6, 2024

I implemented this in https://metacpan.org/release/TINITA/YAML-PP-0.027_002
maybe you want to test it?

from yaml-pp-p5.

karenetheridge avatar karenetheridge commented on June 6, 2024

Awesome! I will try to find some time to test it soon.

from yaml-pp-p5.

perlpunk avatar perlpunk commented on June 6, 2024

I actually had to add the behaviour to PUSH, SPLICE and UNSHIFT, too.

Uploaded https://metacpan.org/release/TINITA/YAML-PP-0.028

Please reopen if there are any problems :)

from yaml-pp-p5.

karenetheridge avatar karenetheridge commented on June 6, 2024

Thanks!

Unfortunately, I found a bug. Here is a small repro case:

#!/usr/bin/env perl
use strict;
use warnings;
use YAML::PP 0.029;
use YAML::PP::Common qw(PRESERVE_ORDER PRESERVE_FLOW_STYLE);

my $yaml = YAML::PP->new(
    preserve => PRESERVE_ORDER | PRESERVE_FLOW_STYLE,
);

my $source = <<'YAML';
---
alpha: {}
YAML

my $data = $yaml->load_string($source);

$data->{alpha} = {};
$data->{alpha}{beta} = {};
$data->{alpha}{beta}{gamma}[0] = { name => 'value' };

print $yaml->dump_string($data);
__END__
got:
---
alpha:
  beta:
    gamma:
    - {}

expecting:
---
alpha:
  beta:
    gamma:
    - name: value

There is no bug if we start out with $data = {} rather than using $source from the loaded string.

from yaml-pp-p5.

karenetheridge avatar karenetheridge commented on June 6, 2024

Nice, that works a lot better! \o/

from yaml-pp-p5.

perlpunk avatar perlpunk commented on June 6, 2024

Great, thanks for testing =)
I will release it in the next couple of days

from yaml-pp-p5.

karenetheridge avatar karenetheridge commented on June 6, 2024

thanks again!

from yaml-pp-p5.

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.