この JSON は別のファイルにあります。
{
"TestModel" : [
{"query" : "select * from ci_lmaggregation.elementstest where hash_aggregation_key = 0 ALLOW FILTERING "},
{"query" : "select * from ci_lmaggregation.elementstest where hash_aggregation_key = 1 ALLOW FILTERING "},
{"query" : "select * from ci_lmaggregation.elementstest where hash_aggregation_key = 2 ALLOW FILTERING "}
]
}
}
私は彼らのクイックスタートに従おうとしていますが、「decodeOption」や「Parse.parse」なども見つかりません。私は非常に混乱していますか?
val input_file = "[path]/FeatureMapping.json"
val json_content = scala.io.Source.fromFile(input_file).mkString
//it can't find decodeOption
val json_data = json_content.decodeOption[List[Person]].getOrElse(Nil)
//or Parse.parse (which should work given this http://argonaut.io/doc/parsing/)
val jdata = Parse.parse(json_content)
そのため、自分がやりたいことを達成する方法が完全にはわかりません。私はこれに従ってみました: Scala Argonaut を使用して JSON 配列を解析する
そして彼らのウェブサイトの入門ガイドですが、どちらもここのように配列のケースを処理する方法の例を持っていないようです. また、SO投稿のコード例では、codec3が存在しないと表示されるため、私も混乱しています。
ファイルから文字列としてクエリの配列が必要なだけですが、Python のようにこれを行う簡単な方法がないのはなぜですか?