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

Extracting Seq of Seqs #13

Open
conikeec opened this issue Apr 8, 2014 · 0 comments
Open

Extracting Seq of Seqs #13

conikeec opened this issue Apr 8, 2014 · 0 comments

Comments

@conikeec
Copy link

conikeec commented Apr 8, 2014

Attempting to extract a Seq[Seq[String]] from this document

val json = JsonParser("""{
    "vmaz" : {
        "a" : {
            "b" : [ 
                {
                    "c" : {
                        "d" : [ 
                            {
                                "name" : "[Internal RAID10] 123",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 6443746134
                            }, 
                            {
                                "name" : "[Internal RAID10] 456",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 0
                            }, 
                            {
                                "name" : "[Internal RAID10] 789",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 25769803776
                            }, 
                            {
                                "name" : "[Internal RAID10] 111",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 0
                            }, 
                            {
                                "name" : "[Internal RAID10] 123",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 3615490048
                            }
                        ]
                    }
                }, 
                {
                    "c" : {
                        "d" : [ 
                            {
                                "name" : "11aa",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 6443746148
                            }, 
                            {
                                "name" : "22aa",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 0
                            }, 
                            {
                                "name" : "33aa",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 1006686208
                            }, 
                            {
                                "name" : "44aa",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 0
                            }, 
                            {
                                "name" : "55aa",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 413696
                            }
                        ]
                    }
                }, 
                {
                    "c" : {
                        "d" : [ 
                            {
                                "name" : "66aaa",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 6443746148
                            }, 
                            {
                                "name" : "77aaa",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 0
                            }, 
                            {
                                "name" : "88aaaa",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 15451869184
                            }, 
                            {
                                "name" : "999aaa",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 0
                            }, 
                            {
                                "name" : "10900assas",
                                "datastoreId" : "datastore-66",
                                "sizeInBytes" : 17190912
                            }
                        ]
                    }
                }
            ]
        }
    }
}""")

json.extract[Seq[Seq[String]]](fromPath("$.vm.a.b[*].c.d[*].name"))

I attempted other combinations and realized that it seems to be flattening it to a Seq[String]. I wouldn't want this but rather a Seq[Seq[String]] in order to preserve the alignment.

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

No branches or pull requests

1 participant