stacycurl / pimpathon

Adds useful methods to scala & java classes.
Apache License 2.0
35 stars 9 forks source link

Feature request - JsonFrills.descendant, ability to select an object from array based on a attribute values #255

Closed timt closed 8 years ago

timt commented 8 years ago

e.g.

    val json = {
        "repeatingThings" : [
            {
                "id" : "123",
                "country" : "United Kingdom",
                "summary" : "Summarise this",
                "canI" : true
            }
        ]
    }

    json.getAll.descendant("repeatingThings/*[country='United Kingdom']/summary").string shouldBe "Summaries this"

For inspiration see: http://www.w3schools.com/xsl/xpath_examples.asp

stacycurl commented 8 years ago

I've done this for string values, would need further work to generalise the type of value && the complexity of the predicate [country/something = 'something'], [country = x && canI == true], [country = x || canI == true], etc.