Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializing Date failed new with 2.6.1 #222

Closed
jans23 opened this issue Sep 2, 2015 · 6 comments
Closed

Serializing Date failed new with 2.6.1 #222

jans23 opened this issue Sep 2, 2015 · 6 comments
Milestone

Comments

@jans23
Copy link

jans23 commented Sep 2, 2015

The following test fails with jackson-module-scala 2.6.1 but succeeded in earlier versions including 2.6.0-1:

private val dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
val myDate = DateClass(dateFormat.parse("2013-03-02T23:56:27Z"))
val myDateJson = "{\n  \"my_date\" : \"2013-03-02T23:56:27Z\"\n}"

test("Serialize Date object to JSON string") {
  assertResult(myDateJson) { serialize(myDate) }
}

Test results:

Serialize Date object to JSON string *** FAILED ***
Expected "...ate" : "2013-03-02T2[3]:56:27Z"
}", but got "...ate" : "2013-03-02T2[2]:56:27Z"

I use the following wrapper:

object JacksonWrapper extends LazyLogging {
  private val dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
  val mapper = new ObjectMapper() with ScalaObjectMapper
  mapper.registerModule(DefaultScalaModule)
  mapper.setDateFormat(dateFormat)

  // ...
}
@cowtowncoder
Copy link
Member

Is this specific to Scala module? Or does it also fail with standard databind ObjectMapper?
If latter, it should be filed under jackson-databind.

@jans23
Copy link
Author

jans23 commented Sep 15, 2015

I don't know because I don't use Java.

@christophercurrie
Copy link
Member

@cowtowncoder are there changes in databind that might be related here? IIRC there aren't any changes in the Scala module between 2.6.0-1 and 2.6.1.

@christophercurrie christophercurrie added this to the 2.6.2 milestone Sep 15, 2015
@cowtowncoder
Copy link
Member

@christophercurrie The only change that seems even remotely related would be:

FasterXML/jackson-databind#889

but I don't see how it would directly affect things here.

@christophercurrie
Copy link
Member

Didn't check the cross reference until just now. It looks like this is fixed in jackson-databind 2.6.3; we'll get a matching Scala module release ASAP, but in the interim the versions should be cross-compatible.

@jans23
Copy link
Author

jans23 commented Oct 29, 2015

I can confirm that this issue is fixed in 2.6.3. Thank you.

@jans23 jans23 closed this as completed Oct 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants