Hi!
I am trying to create a decoder function which could return a list of
"Tags" from json file like this one:
{
"aggregations" : {
"tags" : {
"by_field" : {
"buckets" : [ { --bucket structure explanation is posted below
"key" : "grade",
"values" : {
"buckets" : [ {
"key" : "prvi",
"doc_count" : 56
}, {
"key" : "drugi",
"doc_count" : 53
}, {
"key" : "trtji",
"doc_count" : 47
}, {
"key" : "četrti",
"doc_count" : 45
} ]
}
}, {
"key" : "term",
"values" : {
"buckets" : [ {
"key" : "drugi",
"doc_count" : 70
}, {
"key" : "prvi",
"doc_count" : 69
}, {
"key" : "tretji",
"doc_count" : 62
} ]
}
}]
}
}
}
}
Tag-type looks like this:
type alias Tag =
{ name : String
, value : String
, doc_count : Int
}
I know the parts like how to get to the first buckets property etc, but
can't find a way to create a decoder which would, in my opinion the best
solution, pass down the name_value and resolve value and doc_count values
as separate Tags later. What's the best way to do that?
additional informations:
-- BUCKET STRUCTURE
-- each tag_name holds up values of multiple tags, and each value of a tag
also displays doc_count value
{
"key": "<tags_name>",
"values": {
"buckets": [{
"key": "<tag_value>",
"doc_count": <tag_doc_count>
}, {
"key": "drugi",
"doc_count": 53
}, {
"key": "trtji",
"doc_count": 47
}, {
"key": "četrti",
"doc_count": 45
}]
}
}
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.