It's my first time using argonauts and only have a small knowledge of lenses (enough to get by). I've spent a while trying to figure out the problem myself but getting nowhere.
I'm trying to build a lens to get a JsonArray (of Strings) from some JSON. I can get as far as the Object that has the Array but not sure what to do from there.
The JSON looks like:
And my lens so far is this:
val hashtagsView = twitterEntitiesView >=> jsonObjectPL("hashtags") >=> jArrayPL
I'm not sure if that jArrayPL is correct either. What I would like to do is just retrieve the text from the Array.
So to wrap up, can anyone help me in finding out how to construct a lens that looks into hashtags and then for each element of the array look into the text, finally getting a values as a JsonArray.
Update:
With some help from Travis I have the following code compiling:
import argonaut._, Argonaut._
import monocle.std.list._, monocle.function.Each.each, monocle.function.Index.index
import scalaz._, Scalaz._
val \/-(json) = Parse.parse(rawJSON)
val lens = jObjectPrism
.composeOptional(index("hashtags"))
.composePrism(jArrayPrism)
.composeTraversal(each[List[Json], Json])
.composePrism(jObjectPrism)
.composeOptional(index("text"))
.composePrism(jStringPrism)
println(lens.getAll(json))
Unfortunately, I get a runtime error: scalaz.Scalaz$.ToEitherOps(Ljava/lang/Object;)Lscalaz/syntax/EitherOps; starting at the line val \/-(json) = Parse.parse(rawJSON)
Thanks in advance!
