Skip to content

Commit

Permalink
Merge pull request #875 from guardian/ash/play-json-extensions
Browse files Browse the repository at this point in the history
Drop `play-json-extensions` dependency
  • Loading branch information
AshCorr authored Apr 26, 2024
2 parents 4c6c389 + ef8ddde commit c313cee
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
41 changes: 37 additions & 4 deletions app/jsonimplicits/implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import java.time.{Instant, ZoneId, ZoneOffset}

import _root_.model.{Owner, SSA}
import agent._
import ai.x.play.json.Encoders.encoder
import ai.x.play.json.Jsonx
import collectors._
import org.joda.time.DateTime
import org.joda.time.format.ISODateTimeFormat
Expand Down Expand Up @@ -73,8 +71,43 @@ object model {
Json.writes[RecurringCharge]
Json.writes[Reservation]
}
// this case class contains over 22 fields, which is more than Scala permits, so using the play-json-extensions library instead of the normal Json.writes
implicit val rdsWriter: Writes[Rds] = Jsonx.formatCaseClass[Rds]
// json-play does not support automatically generating a writer for case clases with 22+ fields.
// Manually write one to get around this limitation.
implicit val rdsWriter: Writes[Rds] = OWrites[Rds](obj =>
JsObject(
Seq(
"arn" -> Json.toJson(obj.arn),
"allocatedStorage" -> Json.toJson(obj.allocatedStorage),
"availabilityZone" -> Json.toJson(obj.availabilityZone),
"secondaryAvailabilityZone" -> Json.toJson(
obj.secondaryAvailabilityZone
),
"engineVersion" -> Json.toJson(obj.engineVersion),
"instanceCreateTime" -> Json.toJson(obj.instanceCreateTime),
"dbInstanceClass" -> Json.toJson(obj.dbInstanceClass),
"dbInstanceStatus" -> Json.toJson(obj.dbInstanceStatus),
"caCertificateIdentifier" -> Json.toJson(obj.caCertificateIdentifier),
"dbiResourceId" -> Json.toJson(obj.dbiResourceId),
"dbInstanceIdentifier" -> Json.toJson(obj.dbInstanceIdentifier),
"engine" -> Json.toJson(obj.engine),
"publiclyAccessible" -> Json.toJson(obj.publiclyAccessible),
"iamDatabaseAuthenticationEnabled" -> Json.toJson(
obj.iamDatabaseAuthenticationEnabled
),
"performanceInsightsEnabled" -> Json.toJson(
obj.performanceInsightsEnabled
),
"multiAZ" -> Json.toJson(obj.multiAZ),
"storageEncrypted" -> Json.toJson(obj.storageEncrypted),
"vpcId" -> Json.toJson(obj.vpcId),
"dbSubnetGroupName" -> Json.toJson(obj.dbSubnetGroupName),
"vpcSecurityGroupId" -> Json.toJson(obj.vpcSecurityGroupId),
"storageType" -> Json.toJson(obj.storageType),
"autoMinorVersionUpgrade" -> Json.toJson(obj.autoMinorVersionUpgrade),
"tags" -> Json.toJson(obj.tags)
)
)
)

implicit val domainResourceRecordWriter: Writes[DomainResourceRecord] =
Json.writes[DomainResourceRecord]
Expand Down
5 changes: 0 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ lazy val root = (project in file("."))
"com.amazonaws" % "aws-java-sdk-autoscaling" % awsVersionOne,
"org.playframework" %% "play-json" % "3.0.2",
"org.playframework" %% "play-json-joda" % "3.0.2",
"ai.x" %% "play-json-extensions" % "0.42.0",
ws,
"org.scala-stm" %% "scala-stm" % "0.11.1",
filters,
Expand All @@ -69,10 +68,6 @@ lazy val root = (project in file("."))
"ch.qos.logback" % "logback-classic" % "1.5.6",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.17.0"
),
excludeDependencies ++= Seq(
// As of Play 3.0, groupId has changed to org.playframework; exclude transitive dependencies to the old artifacts
ExclusionRule(organization = "com.typesafe.play")
),
scalacOptions ++= List(
"-encoding",
"utf8",
Expand Down
3 changes: 0 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.2")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0")
Expand Down

0 comments on commit c313cee

Please sign in to comment.