jsonfeed4j

Read and write JSON Feed, as defined at https://jsonfeed.org

Лицензия

Лицензия

Категории

Категории

MOA Прикладные библиотеки Machine Learning JSON Данные
Группа

Группа

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

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

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

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

0.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

jsonfeed4j
Read and write JSON Feed, as defined at https://jsonfeed.org
Система контроля версий

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

https://github.com/mwanji/jsonfeed4j

Скачать jsonfeed4j

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

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

Зависимости

provided (1)

Идентификатор библиотеки Тип Версия
javax.validation : validation-api jar 1.1.0.Final

test (1)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-api jar 5.0.0-M4

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

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

jsonfeed4j

jsonfeed4j is a JSON Feed reader and writer for Java 8+.

Installation

Requires Java 1.8 or above.

Add the following dependency to your POM (or equivalent for other dependency managers):

<dependency>
  <groupId>com.moandjiezana.jsonfeed</groupId>
  <artifactId>jsonfeed4j-gson</artifactId>
  <version>1.0.0-SNAPSHOT</version>
</dependency>

This binds jsonfeed4j to the Gson JSON library. If you wish to use another JSON library, you must implement your own JsonFeedReader.

Quick Start

JsonFeed jsonFeed = new GsonJsonFeedReader().read(getJsonFeedFile());
System.out.println("Author: " + jsonFeed.getAuthor().orElse(""));
jsonFeed.getItems().stream().map(Item::getUrl).forEach(System.out::println);

Validation

jsonfeed4j uses standard Bean Validation 1.1 (spec) annotations to enforce JSON Feed's required fields. However, no implementation is included, so validation can be performed with whichever implementation you prefer, such as Hibernate Validator. Custom validators are provided for cases in which there are several optional fields, but at least one must be present. Examples include item.content_text and item.content_text.

Optional fields are wrapped in an Optional to make it obvious.

Validator validator = getValidator();
JsonFeed jsonFeed = getJsonFeed();

Set<ConstraintViolations<?>> violations = validator.validate(jsonFeed);

Extensions

JSON Feed allows extensions at every level. All jsonfeed4j model classes have a Extensions getExtensions() method. From the Extensions object, you can retrieve the extension's root by its name without the underscore. For example:

{
  "_plugin1": {
    "key": "value"
  },
  "_plugin2": [ "a", "b", "c"],
  "_plugin3": "value2",
  "items": [
    {
      "id": "http://example.org/1",
      "content_text": "Some text",
      "_plugin4": 1234
    }
  ]
}
JsonFeed jsonFeed = getJsonFeed();
Extensions topLevelExtensions = jsonFeed.getExtensions();

Map<String, ?> plugin1 = topLevelExtensions.getMap("plugin1");
List<?> plugin2 = topLevelExtensions.getList("plugin2");
Object plugin3 = topLevelExtensions.get("value2");
Object plugin4 = jsonFeed.getItems().get(0).getExtensions().get("plugin4");

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

Версия
0.1.0