def toJsonString()

in ideaSupport/src/main/scala/org/jetbrains/sbtidea/productInfo/ProductInfoParser.scala [24:48]


  def toJsonString(productInfo: ProductInfo): String =
    productInfo.toJson(productInfoFormat).prettyPrint

  private implicit def productInfoFormat: RootJsonFormat[ProductInfo] = jsonFormat8(ProductInfo)
  private implicit def launchFormat: JsonFormat[Launch] = jsonFormat8(Launch)
  private implicit def layoutItemFormat: RootJsonFormat[LayoutItem] = jsonFormat3(LayoutItem)

  private implicit def layoutItemKindFormat: JsonFormat[LayoutItemKind] = new JsonFormat[LayoutItemKind] {
    override def read(json: JsValue): LayoutItemKind = json match {
      case JsString(value) => value match {
        case "moduleV2" => LayoutItemKind.ModuleV2
        case "plugin" => LayoutItemKind.Plugin
        case "pluginAlias" => LayoutItemKind.PluginAlias
        case "productModuleV2" => LayoutItemKind.ProductModuleV2
        case value =>
          log.warn(s"Unknown layout item kind: $value")
          //use special "Unknown" case class to be more fail-tolerant
          LayoutItemKind.Unknown(value)
      }
      case _ =>
        deserializationError("LayoutItemKind expected")
    }

    override def write(obj: LayoutItemKind): JsValue = JsString(obj.toString)
  }