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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:19:09+00:00 2026-06-05T17:19:09+00:00

I have a relatively simple object with a method that makes an HTTP request.

  • 0

I have a relatively simple object with a method that makes an HTTP request. The request automatically extracts the data according to class type and spits out the necessary object.

The problem is that I can’t seem to reference the class dynamically. The code:

object abstractObject extends APIResource {

  def retrieve(clazz: String, key: String) = { 
    request("GET", instanceURL(key)).extract[clazz]
  }

}

clazz defines a type that is to be passed on to extract which allows the request to parse a JSON hash on-the-fly into an object. I need to somehow use that String to dynamically reference the class type and pass it to extract.

Any ideas or will I need to re-architect this?

  • 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-05T17:19:11+00:00Added an answer on June 5, 2026 at 5:19 pm

    Types only exist at compile time, so you can’t go from a run-time value to a type. Well, you can with Scala 2.10’s reflection, which would essentially get the code you need generated at run time, and then executed. You’d need to bundle both compiler and reflection jar files with the application.

    However, none of that should be required for what you are proposing. A Class or Manifest object is enough — though, of course, maybe the API you are using doesn’t provide such alternative.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a relatively simple HTML / JavaScript form. Such as this: <form method='POST'
I have a relatively simple question. Will using PHP guarantee that a form is
I have a relatively simple class which deletes a post: function delete_post($postid, $reason){ //Stuff
I have a relatively simple question that I cannot seem to find the answer
I have this relatively simple regex for usernames // Enforce that username has to
I have a relatively simple ASP.net MVC 2 app that is using SubSonic. Everything
I have a relatively simple abstract class. I've simplified it further for this question.
I have a relatively large set of data that lends itself very naturally to
I have what should be a relatively simple question that I can't seem to
Assume that I have the following object public class MyClass { public ReadOnlyDictionary<T, V>

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.