Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9134167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:36:46+00:00 2026-06-17T08:36:46+00:00

After reading a JSON result from a web service response: val jsonResult: JsValue =

  • 0

After reading a JSON result from a web service response:

val jsonResult: JsValue = Json.parse(response.body)

Containing content something like:

{
    result:  [
    ["Name 1", "Row1 Val1", "Row1 Val2"],
    ["Name 2", "Row2 Val1", "Row2 Val2"]
             ]
 }

How can I efficiently map the contents of the result array in the JSON with a list (or something similar) like:

val keys = List("Name", "Val1", "Val2")

To get an array of hashmaps?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:36:47+00:00Added an answer on June 17, 2026 at 8:36 am

    Something like this ?
    This solution is functional and handles None/Failure cases “properly” (by returning a None)

    val j = JSON.parseFull( json ).asInstanceOf[ Option[ Map[ String, List[ List[ String ] ] ] ] ]
    
    val res = j.map { m ⇒
        val r = m get "result"
        r.map { ll ⇒
            ll.foldRight( List(): List[ Map[ String, String ] ] ) { ( l, acc ) ⇒
                Map( ( "Name" -> l( 0 ) ), ( "Val1" -> l( 1 ) ), ( "Val2" -> l( 2 ) ) ) :: acc
            }
        }.getOrElse(None) 
    }.getOrElse(None) 
    
    • Note 1: I had to put double quotes around result in the JSON String to get the JSON parser to work
    • Note 2: the code could look nicer using more “monadic” sugar such as for comprehensions or using applicative functors
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse JSON response from a httpwebrequest fetch and a little
After reading monkeytalk faq from http://www.gorillalogic.com/testing-tools/monkeytalk/documentation/monkeytalk-faq : How does it all work? MonkeyTalk is
After reading the Service Oriented Architecture Principles site and the respective Wikipedia article I
After reading this article, it makes sense to rebase to gather changes from the
My problem is html content not being parsed with JSON.parse . I am getting
Scenario After reading this answer I realized that I could create object starting from
I had created a Django view which is returning some data after reading from
I'm using JSON to get a System.Net.WebResponse then reading the response into a StringBuilder
As iam trying to post the result of rating activity. After reading the rating
I am reading points from a DB as JSON to create map markers and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.