<commit_before>package com.github.jancajthaml.jwt

object jsondumps extends (Map[String, Any] => String) {
  
  def apply(value: Map[String, Any]): String = {
    //@todo string construction hogs this, should refactor to
    //recursion returning chunks of Array[Byte] in sudo parallel
    var vector: Vector[Any] = Vector[Any]()
    var nothing: Vector[Any] = Vector.empty :+ ":null,"

    value.map(x => x._2 match {
      case d: String => vector ++= ('"' +: x._1.asInstanceOf[String] +: '"' +: ':' +: '"' +: x._2.asInstanceOf[String] :+ "\",")
      case null => vector = (vector ++ ('"' +: x._1.asInstanceOf[String] :+ '"') ++ nothing)
      case c => vector ++= ('"' +: x._1.asInstanceOf[String] +: '"' +: ':' +: x._2.toString :+ ',')
    })

    '{' + vector.dropRight(1).mkString + '}'
  }
}

object jsonloads extends (String => Map[String, Any]) {

  def apply(value: String): Map[String, Any] = {
    //@todo check string contains nested json (more than one "{" or "}")
    //because we do not support nested json strucures @todo TBD
    var loaded = Map[String, Any]()

    //@todo declaration of this loopuk table in function wastes perf, move outside
    /*
      (t|f) => boolean (true|false)
      (0|1|2|3|4|5|6|7|8|9) => integral number (decimals unsuported)
      (") => string<commit_msg>moved trailing quote outside of match<commit_after>package com.github.jancajthaml.jwt

object jsondumps extends (Map[String, Any] => String) {
  
  def apply(value: Map[String, Any]): String = {
    //@todo string construction hogs this, should refactor to
    //recursion returning chunks of Array[Byte] in sudo parallel
    var vector: Vector[Any] = Vector[Any]()
    var nothing: Vector[Any] = Vector.empty :+ ":null,"
    var trail: Vector[Any] = Vector.empty :+ "\","

    value.map(x => x._2 match {
      case d: String => vector = (vector ++ ('"' +: x._1.asInstanceOf[String] +: '"' +: ':' +: '"' +: x._2.asInstanceOf[String]) ++ trail)
      case null => vector = (vector ++ ('"' +: x._1.asInstanceOf[String] :+ '"') ++ nothing)
      case c => vector ++= ('"' +: x._1.asInstanceOf[String] +: '"' +: ':' +: x._2.toString :+ ',')
    })

    '{' + vector.dropRight(1).mkString + '}'
  }
}

object jsonloads extends (String => Map[String, Any]) {

  def apply(value: String): Map[String, Any] = {
    //@todo check string contains nested json (more than one "{" or "}")
    //because we do not support nested json strucures @todo TBD
    var loaded = Map[String, Any]()

    //@todo declaration of this loopuk table in function wastes perf, move outside
    /*
      (t|f) => boolean (true|false)
      (0|1|2|3|4|5|6|7|8|9) => integral number (decimals unsuported)
      (") => string
{'fraction_non_alphanumeric': 0.18710633567988144, 'fraction_numerical': 0.012597258243793997, 'mean_word_length': 3.313099041533546, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 21, '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': '931646', 'n_tokens_mistral': 934, 'n_tokens_neox': 911, 'n_words': 240}