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 7030855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:43:36+00:00 2026-05-28T00:43:36+00:00

This is probably an easy one and my difficulty is likely caused by my

  • 0

This is probably an easy one and my difficulty is likely caused by my newness to Scala (which already is fast becoming my favourite language).

Basically I have some JSON that looks like this:

{
"to"      : "Peter",
"from"    : "Dave",
"bundle"  : [
             {"data": [1,2,3,4,5]},
             {"data": [2,3,4,5,6]}
            ]

}

Now, I’ve parsed this JSON to the point where I can pull the data from the header (to and from) and can look over the individual messages in the bundle. At the moment I’m using this:

val messages = parsedJSON \\ "bundle" \\ classOf[JObject]

for (m <- messages) println(m)

Which gives me:

Map(data -> List(1, 2, 3, 4, 5))
Map(data -> List(2, 3, 4, 5, 6))

But what I want to do in that loop is take each Map and convert it back to JSON i.e.:

{
"data": [1,2,3,4,5]
}

I’ve tried render(m) and various other semi-random things to try and get it to work but so far no dice. The closest I’ve come gives me this error:

No implicit view available from Any => net.liftweb.json.package.JValue.

Can anyone please point me in the right direction?

Thanks in advance!

  • 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-05-28T00:43:36+00:00Added an answer on May 28, 2026 at 12:43 am

    I think the easiest way to handle this is to create a case class for a bundle. Lift-json can then nicely extract the data into instances. Then you can just loop through them and turn them back into JObjects implicitly by creating 2-tuples.

    case class Bundle(data: List[BigInt])
    
    val bundles = (parsedJSON \\ "bundle").extract[List[Bundle]]
    // List(Bundle(List(1, 2, 3, 4, 5)), Bundle(List(2, 3, 4, 5, 6)))
    bundles
      .map{ bundle => ("data" -> bundle.data)}
      .foreach{ j => println(compact(render(j)))}
    //{"data":[1,2,3,4,5]}
    //{"data":[2,3,4,5,6]}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably an easy one for a GUI programmer, which I'm not... In
Morning y'all This is probably an easy one but I barely got any sleep
This is probably one of those easy questions.. I'm trying to redirect the user
This is probably an easy one, but is the right way to calculate volume
This is probably an easy one. I have about 20 TextViews/ImageViews in my current
So, here's the problem (it's probably an easy one :P) This is my table
Relatively new to mySQL so this is probably an easy one: I have a
This is probably an easy one for some of you. I'm trying to test
This is probably an easy one... I have a Listbox with a ContextMenu embedded
I barely understand rails, let alone ruby, so this is probably an easy one.

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.