question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is It possible to add different Object type into ReflectedYamlDump?

See original GitHub issue

I’m using a library that allows me to manage yaml and json files and in that case;

"test-scalar-type": "test-scalar-type"
"test-section":
  "test-section-scalar-type": "test-scalar-type"

“test-section” is a ConfigurationSection in my library and when I use dump() method. and It gives me StackOverFlow because It must return Map or Scalar stuffs. And I resolve that problem with editing the ReflectYamlDump class like that;

@Override
public YamlNode dump() {
    final YamlNode node;
    if (this.object == null || ReflectedYamlDump.SCALAR_TYPES.contains(this.object.getClass())) {
        node = new ReflectedYamlScalar(this.object);
    } else if (this.object instanceof Collection || this.object.getClass().isArray()) {
        node = new ReflectedYamlScalar(this.object);
    } else if (this.object instanceof ConfigurationSection) {
        node = new ReflectedYamlMapping(((ConfigurationSection) this.object).getValues(false));
    } else {
        node = new ReflectedYamlMapping(this.object);
    }
    return node;
}

It’s really temporary fix. And I want to know that how we can add a custom object into ReflectedYamlDump class without editing the library.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
amihaiemilcommented, Jun 3, 2020

@portlek I think I understand now. It seems like an interesting feature, I’ll have a look 😃

0reactions
amihaiemilcommented, Jun 7, 2020

ok then, closing this 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dumping custom class objects to a YAML file - Stack Overflow
Dumping custom class objects to a YAML file ; # requisite imports here, based on # how the files are stored from ;...
Read more >
A Powerful Python Trick: Custom YAML tags & PyYAML
A simple yet powerful way to improve the way you write and use configuration files in Python.
Read more >
YAML: The Missing Battery in Python
Dumping Python Objects to YAML Documents. Choose the Dumper Class; Dump to a String, a File, or a Stream; Dump Multiple Documents ...
Read more >
Dumping Python classes - ruamel.yaml - Read the Docs
User originates from the name of the class. You can specify a different tag by adding the attribute yaml_tag , and explicitly specify...
Read more >
Yaml (SnakeYAML 1.19 API) - javadoc.io
Create Yaml instance. It is safe to create a few instances and use them in different Threads. Yaml. public Yaml(DumperOptions dumperOptions).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found