Skip to content

Instantly share code, notes, and snippets.

@simong
Created December 12, 2015 06:31
Show Gist options
  • Save simong/8323d2267b22ab98a40c to your computer and use it in GitHub Desktop.
Save simong/8323d2267b22ab98a40c to your computer and use it in GitHub Desktop.

The JSON I'd like to end up with:

[
    {
        "name": "HeadingsResult",
        "score": 0.813,
        "data": {
            "levels": {
                "h1": 0,
                "h2": 3,
                "h3": 7
            }
        }
    },
    {
        "name": "TitleResult",
        "score": 0,
        "data": {
            "titleMissing": false
        }
    },
    {
        "name": "AltResult",
        "score": 0.32,
        "data": {
            "imageMissing": 2,
            "totalImages": 7,
            "formulaMissing": 1,
            "totalFormulas": 1
        }
    },
    ...
]

The class structure I have:

sealed abstract class Result
case class HeadingsResult(levels:Map[String, Int]) extends Result
case class TitleResult(titleMissing:Boolean) extends Result
case class AltResult(imageMissing:(Int, Int), formulaMissing:(Int, Int)) extends Result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment