我们得到一个 HttpResponse,其中日期作为一个 json 属性,日期采用 ISO8601 格式(例如 2020-03-13T00:00:35.570+0000),但 Jackson 抛出以下异常:
java.time.format.DateTimeParseException: Text '2020-03-13T00:00:35.570+0000' could not be parsed at index 23
我编写了以下测试(spock),但无法重现。我需要知道如何解析日期。感谢您的帮助!
class TestJackson extends Specification{
def 'test date format'(){
given:
def jsonString = """{"myDate":"2020-03-13T00:00:35.570+0000"}"""
and:
def objectMapper = new ObjectMapper()
.registerModule(new JavaTimeModule())
.enable(SerializationFeature.INDENT_OUTPUT)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
when:
def resp = objectMapper.readValue(jsonString, Response)
then:
resp.myDate != null
}
@Data
@NoArgsConstructor
@AllArgsConstructor
static class Response {
ZonedDateTime myDate
}
}
Run Code Online (Sandbox Code Playgroud)
该测试使用以下依赖项:
我在 NextJs 和 next-images 中使用打字稿。代码是:
import css from "./style.sass";
import img from './logo.svg';
import Link from 'next/link';
export default () => <Link href="/">
<img src={img} className={css.logo}/>
</Link>;
Run Code Online (Sandbox Code Playgroud)
如果没有输入,则显示此错误:
Cannot find module './logo.svg'.ts(2307)
Run Code Online (Sandbox Code Playgroud)
目前我使用以下类型(typings.ts):
Cannot find module './logo.svg'.ts(2307)
Run Code Online (Sandbox Code Playgroud)
使用这些typings.ts 文件应该可以解决错误,但事实并非如此。有没有人在使用时遇到同样的错误?有没有更好的方法来编写typings.ts 文件?
我想使用 Azure 市场中的 Terraform 创建 Sendgrid 订阅。目前我必须使用 UI,但最好创建订阅并自动检索 Terraform 中 Sendgrid 的访问令牌。
azure ×1
jackson ×1
java ×1
json ×1
next.js ×1
sendgrid ×1
spring-boot ×1
terraform ×1
twilio ×1
typescript ×1