Return to site

JAKARTA EE: Bean to/from JSON with JSONB

July 2, 2022

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)

☁ïļ ð‚ðĄðžðœðĪ ð­ðĄðž 𝐜ðĻ𝐝𝐞: