Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 RESTEasy 通过我的带有 JSON 的 rest api 发送对象。这非常方便 - 每个字段都会自动填充到 JSON 对象中。但是有些字段(例如passwordhash)我宁愿不发送。我还想删除任何空值 - 无需发送这些值。
passwordhash
我可以影响 JSON 的创建方式吗?
我正在使用 Jettison、RESTEasy 2.0.1.GA 和我认为的 JAXB,尽管我确实很难确定这一点。
这取决于您使用什么来处理 JSON。如果您使用的是 JAXB 和 Jettison,则可以使用 @XmlTransient 来避免发送带注释的字段。如果您使用的是 Jackson,则可以使用 @JsonIgnore。无论您使用哪个选项,默认情况下都应省略 NULL 值。