Return to site

JAKARTA EE: Bean to/from JSON with JSONB

ยท java,github

Jakarta JSON Binding defines a binding framework for converting Java(R) objects to and from JSON documents.

๐Ÿ“ฆ ๐˜๐จ๐ฎ ๐ง๐ž๐ž๐ ๐ญ๐ฐ๐จ ๐ฆ๐š๐ฏ๐ž๐ง ๐๐ž๐ฉ๐ž๐ง๐๐ž๐ง๐œ๐ข๐ž๐ฌ:

org.eclipse.yasson:1.0.3

org.glassfish.javax.json:1.1.4

๐Ÿ‘ฉโ€๐Ÿซ ๐‡๐จ๐ฐ ๐ญ๐จ:

You define a bean: Drink with some attributes (Name and Price)

You define your main class where you do the converting actions.

๐Ÿ‘จโ€๐Ÿ’ป ๐’๐ง๐ข๐ฉ๐ฉ๐ž๐ญ:

๐Ÿ–จ๏ธ ๐ˆ๐ญ ๐ฉ๐ซ๐ข๐ง๐ญ๐ฌ:

JSONB demo

Drink to proceed:Drink(name=Cola, price=4.0)

To JSON: {"name":"Cola","price":4.0}

From JSON: Drink(name=Cola, price=4.0)

โ˜๏ธ ๐‚๐ก๐ž๐œ๐ค ๐ญ๐ก๐ž ๐œ๐จ๐๐ž: