Added toJson().

This commit is contained in:
Erik C. Thauvin 2020-03-05 22:49:24 -08:00
parent 5550f076ca
commit 527530e89d
4 changed files with 12 additions and 3 deletions

View file

@ -72,7 +72,7 @@ This will ensure that the user's IP, agent, referrer and various environment var
Since comments mis-identified as spam or ham can be submitted to Askimet to improve the service. A comment can be saved as a JSON object to be stored in a database, etc. Since comments mis-identified as spam or ham can be submitted to Askimet to improve the service. A comment can be saved as a JSON object to be stored in a database, etc.
```kotlin ```kotlin
var json = comment.toString() var json = comment.toJson()
``` ```
At a latter time, the comment can the be submitted: At a latter time, the comment can the be submitted:

View file

@ -38,7 +38,7 @@ class AkismetServlet : HttpServlet() {
email = comment.authorEmail, email = comment.authorEmail,
date = comment.dateGmt, date = comment.dateGmt,
comment = comment.content, comment = comment.content,
json = comment.toString(), json = comment.toJson(),
isSpam = isSpam isSpam = isSpam
) )

View file

@ -234,6 +234,15 @@ open class AkismetComment(val userIp: String, val userAgent: String) {
serverEnv = buildServerEnv(request) serverEnv = buildServerEnv(request)
} }
/**
* Returns a JSON representation of the comment.
*
* @see [Akismet.jsonComment]
*/
fun toJson(): String {
return toString()
}
/** /**
* Returns a JSON representation of the comment. * Returns a JSON representation of the comment.
* *

View file

@ -130,7 +130,7 @@ class AkismetTest {
isTest = true isTest = true
} }
akismet.logger.info(mockComment.toString()) akismet.logger.info(mockComment.toJson())
} }
@Test @Test