I have a JSON schema as shown below:
"elements": {
      "{element1Name}": {
        "value": "<p>The HTML content of the element.</p>",
        ":type": "text/html",
        "variations": {
          "{variation1Name}": {
            "value": "<p>The HTML content of the element.</p>",
            ":type": "text/html"
          },
          "{variation2Name}": {
            "value": "<p>The HTML content of the element.</p>",
            ":type": "text/html"
          },
          "{elementNName}": {
            "value": "<p>The HTML content of the element.</p>",
            ":type": "text/html"
          }
        }
      },
      "{element2Name}": {
        "value": "<p>The HTML content of the element.</p>",
        ":type": "text/html",
        "variations": {
          "{variation1Name}": {
            "value": "<p>The HTML content of the element.</p>",
            ":type": "text/html"
          },
          "{variation2Name}": {
            "value": "<p>The HTML content of the element.</p>",
            ":type": "text/html"
          },
          "{elementNName}": {
            "value": "<p>The HTML content of the element.</p>",
            ":type": "text/html"
          }
        }
      },
      "{elementNName}": {
        "value": "<p>The HTML content of the element.</p>",
        ":type": "text/html",
        "variations": {
          "{variation1Name}": {
            "value": "<p>The HTML content of the element.</p>",
            ":type": "text/html"
          },
          "{variation2Name}": {
            "value": "<p>The HTML content of the element.</p>",
            ":type": "text/html"
          },
          "{elementNName}": {
            "value": "<p>The HTML content of the element.</p>",
            ":type": "text/html"
          }
        }
      }
    }
Which I am able to replicate as following case classes:
case class AssetAPIEntity(
  value: String,
  @key(":type") `type`: Option[String] = None,
                         )
case class AssetAPIElements(
                             value: String,
                             @key(":type") `type`: Option[String] = None,
                             variations: Map[String,AssetAPIEntity]
                           )
case class AssetAPIData(
  title: Option[String] = None,
  description: Option[String] = None,
  @key("cq:Model") cqModel: String,
  elements: Map[String,AssetAPIElements]
                       )
Now the problem is that field value could be either of these:
- Single Number
- Single Boolean
- Single String
- Multi Number
- Multi Boolean
- Multi String
I am stuck at point where how can I write a generic syntax to incorporate any of these values? Can someone help? I thought of ADTs but not sure about the syntax. I would want something like this:
case class AssetAPIEntity[T](
  value: String,
  @key(":type") `type`: Option[T] = None,
                         )
or in simple terms:
case class AssetAPIEntity(
  value: String,
  @key(":type") `type`: Option[String | Boolean | Number | Seq[String] | Seq[Boolean] | Seq[Number]] = None,
                         )
 
    