I have a JSON which is an output of another application, I want to make dynamic Scala code (*.scala file ) from this JSON (can not pre define class/bean as the JSON structure depends many other parameters). Is there any API available for this ?
2 Answers
You can use something like below:
http://json2caseclass.cleverapps.io/
https://www.reddit.com/r/scala/comments/36m951/json2caseclass_a_tool_to_generate_scala_case/
2 Comments
Isabel Jinson
Looks like a web application.. I want an API which is compatible with my existing Scala code.
mathieu
json2caseclass.cleverapps.io is not answering this specific question, but it's a nice tool!
Please have a look at this one: https://github.com/julianpeeters/case-class-generator
Allows runtime data to serve as Scala case class definitions:
Case classes defined and loaded at runtime Pseudo Type-Provider via type alias
And also this one: Maybe this one is better, you need to generate some code first, and then call it.
val loadedInstance: AnyRef = generateAndLoad(json)... Now what? How will you be using this variable?