<commit_before>package com.ephox.argonaut.demo

import com.ephox.argonaut.StringWrap._
import com.ephox.argonaut.Identity._
import com.ephox.argonaut.{Json, PossibleJson, ContraPossibleJson}

object Demo {

  def d[A : ContraPossibleJson](k: A) {
    import Json._

    val j = k.pjson

    // searches down through objects with the keys and obtains the number value at that level
    val a: Option[JsonNumber] = j -| "abc" -| "def" number

    // searches down through objects with the list of keys and returns the JSON string value or the empty string
    val b: JsonString = j -|| List("ghi", "jkl", "mno") stringOrEmpty

    // If it is a JSON object a "abc" field
    val c: Boolean = j hasField "pqr"

    // If it is a number, add ten to it
    val d: PossibleJson = j withNumber (10+)

    // If it is a JSON array, return it, or default to List(jNull, jTrue)
    val e: JsonArray = j arrayOr (List(jNull, jTrue))

    // If it is a JSON object, with a field "xyz" that is a JSON number, return it, otherwise, default to 42
    val f: JsonNumber = j -| "xyz" numberOr 42D

    // If it is a JSON object, prepend the given key/value pairs to it
    val g: PossibleJson = ("k1", jString("v1")) ->: ("k2", jTrue) ->: j

    // If it is a JSON array, prepend the given JSON values to it
    val h: PossibleJson = jFalse -->>: jString("boo") -->>: j

    // If it is a JSON number, return a List containing "cuisine" that many times, otherwise List("brochure", "bakery")
    val i: List[String] = j usingNumber (n => List.fill(n.toInt)("cuisine"), List("brochure", "bakery"))

    List(("a", a), ("b", b), ("c", c), ("d", d), ("e", e), ("f", f), ("g", g), ("h", h), ("i", i))
      foreach { case (x, y) => println(x + " : " + y) }
    
    println
  }<commit_msg>Super tidy<commit_after>package com.ephox.argonaut.demo

import com.ephox.argonaut.StringWrap._
import com.ephox.argonaut.Identity._
import com.ephox.argonaut.{Json, PossibleJson, ContraPossibleJson}

object Demo {

  def d[A : ContraPossibleJson](k: A) {
    import Json._

    val j = k.pjson

    // searches down through objects with the keys and obtains the number value at that level
    val a: Option[JsonNumber] = j -| "abc" -| "def" number

    // searches down through objects with the list of keys and returns the JSON string value or the empty string
    val b: JsonString = j -|| List("ghi", "jkl", "mno") stringOrEmpty

    // If it is a JSON object a "abc" field
    val c: Boolean = j hasField "pqr"

    // If it is a number, add ten to it
    val d: PossibleJson = j withNumber (10+)

    // If it is a JSON array, return it, or default to List(jNull, jTrue)
    val e: JsonArray = j arrayOr (List(jNull, jTrue))

    // If it is a JSON object, with a field "xyz" that is a JSON number, return it, otherwise, default to 42
    val f: JsonNumber = j -| "xyz" numberOr 42D

    // If it is a JSON object, prepend the given key/value pairs to it
    val g: PossibleJson = ("k1", jString("v1")) ->: ("k2", jTrue) ->: j

    // If it is a JSON array, prepend the given JSON values to it
    val h: PossibleJson = jFalse -->>: jString("boo") -->>: j

    // If it is a JSON number, return a List containing "cuisine" that many times, otherwise List("brochure", "bakery")
    val i: List[String] = j usingNumber (n => List.fill(n.toInt)("cuisine"), List("brochure", "bakery"))

    List(("a", a), ("b", b), ("c", c), ("d", d), ("e", e), ("f", f), ("g", g), ("h", h), ("i", i)) foreach { case (x, y) => println(x + " : " + y) }
    
    println
  }
{'fraction_non_alphanumeric': 0.14695035460992908, 'fraction_numerical': 0.005106382978723404, 'mean_word_length': 3.006818181818182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6534443', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1178, 'n_words': 479}