<commit_before>package com.workday.esclient

import cats.syntax.either._
import io.circe._
import io.circe.syntax._
import io.circe.parser._
import io.circe.generic.auto._
import shapeless.Lazy

//TODO: replace with circe wrapper
object JsonUtils {
  def equals(lhs: String, rhs: String): Boolean = {
    ???
  }

  def toJson[T: Encoder](value: T): String = {
    //val outerJson: String = value.asJson.noSpaces
    //Can't use cursor until we decide the downfield class name we'll be working with.
    //val cursor: HCursor = outerJson.hcursor
    //val innerJson: Json = cursor.downField()
    //getting compile errors here so we might need a custom encoder
    //TODO: make custom encoder if can't fix compile error
    value.asJson.noSpaces
  }

  def mapToJson(rawValue: Map[String, Any]): Map[String, Json] = {
    var value = Map[String, Json]()
    for ((k,v) <- rawValue) {
      val nv = v match {
        case int: Int => int.asJson
        case string: String => string.asJson
        //TODO: potentially wrap this into wildcard case and use try-except to get Map[String,Any]
        case map: Map[String, Any] => {
          val vAsMap = map.asInstanceOf[Map[String,Any]]
          mapToJson(vAsMap).asJson
        }
        case _ => Json.Null
      }
      value = value + (k -> nv)
    }
    return value
  }

  def fromJson[T](value: String): T = {
    //val rawJson = parse(value).getOrElse(Json.Null)
    //TODO: make case classes
    //rawJson.as[T]
    ???
  }
}

abstract class Message() {}
case class StringMessage(x: String) {}
case class IntMessage(x: Int) {}<commit_msg>refactored mapToJson to use the wildcard case for Map[String, Any] to remove sbt warnings<commit_after>package com.workday.esclient

import cats.syntax.either._
import io.circe._
import io.circe.syntax._
import io.circe.parser._
import io.circe.generic.auto._
import shapeless.Lazy

//TODO: replace with circe wrapper
object JsonUtils {
  def equals(lhs: String, rhs: String): Boolean = {
    ???
  }

  def toJson[T](value: T): String = {
    //val outerJson: String = value.asJson.noSpaces
    //Can't use cursor until we decide the downfield class name we'll be working with.
    //val cursor: HCursor = outerJson.hcursor
    //val innerJson: Json = cursor.downField()
    //getting compile errors here so we might need a custom encoder
    //TODO: make custom encoder if can't fix compile error
    //value.asJson.noSpaces
    ???
  }

  def mapToJson(rawValue: Map[String, Any]): Map[String, Json] = {
    var value = Map[String, Json]()
    for ((k,v) <- rawValue) {
      val nv = v match {
        case int: Int => int.asJson
        case string: String => string.asJson
        case _ => {
          try {
            val vAsMap = v.asInstanceOf[Map[String,Any]]
            mapToJson(vAsMap).asJson
          } catch {
            case _: Throwable => Json.Null
          }
        }
      }
      value = value + (k -> nv)
    }
    return value
  }

  def fromJson[T](value: String): T = {
    //val rawJson = parse(value).getOrElse(Json.Null)
    //TODO: make case classes
    //rawJson.as[T]
    ???
  }
}

abstract class Message() {}
case class StringMessage(x: String) {}
case class IntMessage(x: Int) {}
{'fraction_non_alphanumeric': 0.12154180913894932, 'fraction_numerical': 0.0, 'mean_word_length': 2.611672278338945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '6741034', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1022, 'n_words': 311}