Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to read sequence of mappings #447

Closed
moovoo opened this issue May 20, 2021 · 6 comments
Closed

Unable to read sequence of mappings #447

moovoo opened this issue May 20, 2021 · 6 comments
Labels

Comments

@moovoo
Copy link

moovoo commented May 20, 2021

gradle dependencies:
implementation 'com.amihaiemil.web:eo-yaml:5.1.9'

test source code:

import com.amihaiemil.eoyaml.Yaml;
import com.amihaiemil.eoyaml.YamlMapping;
import com.amihaiemil.eoyaml.YamlNode;
import com.amihaiemil.eoyaml.YamlSequence;

import java.io.File;
import java.io.IOException;

public class b {

    static void readYaml(final String fileName) throws IOException {
        System.out.println("--- " + fileName + " ---");
        YamlMapping root = Yaml.createYamlInput(new File(fileName)).readYamlMapping();
        YamlSequence variables = root.yamlSequence("root");
        System.out.println("Size: " + variables.size());
        for (YamlNode node: variables) {
            System.out.println("Node: " + node.toString());
        }
    }

    public static void main(String [] args) throws Exception {
        readYaml("test1.yaml");
        readYaml("test2.yaml");
        readYaml("test3.yaml");
    }
}

Output:

--- test1.yaml ---
Size: 3
Node: ---
string1
...
Node: ---
string2
...
Node: ---
string3
...
--- test2.yaml ---
Size: 1
Node: key: key1
value: value1
--- test3.yaml ---
Size: 3
Node: ---
string1
...
Node: key: key1
value: value1
Node: key: key2
value: value2

test1.yaml:

root:
  - string1
  - string2
  - string3

test2.yaml:

root:
  - key: key1
    value: value1
  - key: key2
    value: value2
  - key: key3
    value: value3

test3.yaml:

root:
  - string1
  - key: key1
    value: value1
  - key: key2
    value: value2

Expected result for test2 would be Size=3 and 3 mappings, but for some reason the lib finds only one.
But If I put single string as first item in the sequence the lib would find all other mappings (test3)

@zoeself
Copy link
Collaborator

zoeself commented May 20, 2021

@moovoo thank you for reporting this. I'll assign someone to take care of it soon.

@zoeself
Copy link
Collaborator

zoeself commented May 20, 2021

@criske this is your task now, please go ahead. Deadline (when this ticket should be closed) is 2021-05-30T13:26:41.482809.

Estimation here is 60 minutes, that's how much you will be paid.

Remember, you don't have to solve everything in this ticket - you can solve it partially and leave todo markers in the code, which will become future tasks.

If you have any questions don't ask me, I'm not a technical person. Open new tickets instead.

If you don't have time or simply don't want to work on this, you can always resign.

@amihaiemil
Copy link
Member

@moovoo there must be a bug, we'll try to fix it. In the meantime, try the following indentation:

root:
  -
    key: key1
    value: value1
  -
    key: key2
    value: value2
  -
    key: key3
    value: value3

If I am not mistaken, we had a similar bug earlier and the above indentation fixed it.

@moovoo
Copy link
Author

moovoo commented May 20, 2021

@amihaiemil thanks for the tip, this indentation way works fine

@amihaiemil amihaiemil added the bug label May 20, 2021
criske added a commit to criske/eo-yaml that referenced this issue May 21, 2021
criske added a commit to criske/eo-yaml that referenced this issue May 21, 2021
criske added a commit to criske/eo-yaml that referenced this issue May 21, 2021
criske added a commit to criske/eo-yaml that referenced this issue May 21, 2021
@amihaiemil
Copy link
Member

@moovoo we just released version 5.2.0 with a fix for this bug. Now it should work fine.

Feel free to open another Issue if you still have problems :D

@zoeself
Copy link
Collaborator

zoeself commented May 21, 2021

@criske thank you for resolving this ticket. I've just added it to your active invoice. You can always check all your invoices and more on the Contributor Dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants