Iterate through JSON in Scala -
sorry if it's basic question. when i'm running following code print testregjs:
val testregjs: seq[jsvalue] = (tr <- testreg) yield json.tojson(tr) note: here testreg list of criteria i.e sequence of object , in above code converted seq[jsvalue].
output:
list({ "registration": { "id": 495, "profile_id": "755" }, "test_center": [{ "id": 487, "registration_id": 495 }] }, { "registration": { "id": 599, "profile_id": "360" }, "test_center": [{ "id": 594, "registration_id": 599 }] }) i want print id above list. how can done?
i added following line desired output:
val regid = testregjs.map(x => (x \ "registration" \ "id").as[int])
Comments
Post a Comment