lundi 20 avril 2015

ConfigSlurper bad result with nested values with same key

Vote count: 0

I'm trying to use the Groovy's ConfigSlurper in a projetct but it happens to have a weird behaviour when the same key appears two times in the configuration. Here is an example :

def struct = """
    node2 {
        subnode21="Test1"
    }
    root1 {
        node2 {
            subnode1="Test2"
            subnode2=node2.subnode21
        }
   }

"""
def config = new ConfigSlurper().parse(struct)

This will produce the following result :

[
    node2:[
        subnode21:Test1
    ],
    root1:[
        node2:[
            subnode1:Test2,
            subnode21:[:],
            subnode2:[:]
        ]
    ]
]

ConfigSlurper seems to consider that subnode2=node2.subnode21 in the root1 closure refers to root1.node2 and not the node2 closure declared above.

Is this a known limitation or am I missing something ?

asked 1 min ago



ConfigSlurper bad result with nested values with same key

Aucun commentaire:

Enregistrer un commentaire