JAX-RS Moshi

Message body reader/writer and parameter converter which uses Moshi.

Лицензия

Лицензия

Категории

Категории

Moshi Данные JSON
Группа

Группа

com.jakewharton
Идентификатор

Идентификатор

jax-rs-moshi
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

JAX-RS Moshi
Message body reader/writer and parameter converter which uses Moshi.
Система контроля версий

Система контроля версий

http://github.com/JakeWharton/jax-rs-moshi

Скачать jax-rs-moshi

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.jakewharton/jax-rs-moshi/ -->
<dependency>
    <groupId>com.jakewharton</groupId>
    <artifactId>jax-rs-moshi</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.jakewharton/jax-rs-moshi/
implementation 'com.jakewharton:jax-rs-moshi:1.0.0'
// https://jarcasting.com/artifacts/com.jakewharton/jax-rs-moshi/
implementation ("com.jakewharton:jax-rs-moshi:1.0.0")
'com.jakewharton:jax-rs-moshi:jar:1.0.0'
<dependency org="com.jakewharton" name="jax-rs-moshi" rev="1.0.0">
  <artifact name="jax-rs-moshi" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.jakewharton', module='jax-rs-moshi', version='1.0.0')
)
libraryDependencies += "com.jakewharton" % "jax-rs-moshi" % "1.0.0"
[com.jakewharton/jax-rs-moshi "1.0.0"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
javax.ws.rs : javax.ws.rs-api jar 2.0.1
com.squareup.moshi : moshi jar 1.5.0

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
com.google.auto.value : auto-value jar 1.4.1

Модули Проекта

Данный проект не имеет модулей.

JAX-RS Moshi JSON Handlers

A message body reader/writer and parameter converter which uses Moshi to handle JSON.

Usage

ResourceConfig resourceConfig = new ResourceConfig();

Moshi moshi = new Moshi.Builder().build();

// Handles any request body marked as consuming application/json.
resourceConfig.register(new MoshiMessageBodyReader(moshi));
// Handles any response body marked as producing application/json.
resourceConfig.register(new MoshiMessageBodyWriter(moshi));
// Handles any parameter annotated with @Json.
resourceConfig.register(new MoshiParamConverterFactory(moshi));

(This example uses Jersey, but any JAX-RS-compatible implementation will work.)

The message body converters allow JSON serialization for request and response bodies:

@POST @Path("register") //
@Consumes(MediaType.APPLICATION_JSON) //
@Produces(MediaType.APPLICATION_JSON) //
public RegisterResponse register(RegisterRequest registerRequest) {
  // ...
}

The parameter converter allow JSON serialization for @Json-annotated parameters.

@POST @Path("checkin") //
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) //
@Produces(MediaType.APPLICATION_JSON) //
public CheckinResponse checkin( //
    @FormParam("user") @Json User user) {
  // ...
}

Download

Gradle:

compile 'com.jakewharton:jax-rs-moshi:1.0.0'

or Maven:

<dependency>
  <groupId>com.jakewharton</groupId>
  <artifactId>jax-rs-moshi</artifactId>
  <version>1.0.0</version>
</dependency>

Snapshot versions are available in the Sonatype 'snapshots' repository: https://oss.sonatype.org/content/repositories/snapshots/

License

Copyright 2017 Jake Wharton

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Версии библиотеки

Версия
1.0.0