-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathOrderProcessor.java
More file actions
36 lines (29 loc) · 899 Bytes
/
OrderProcessor.java
File metadata and controls
36 lines (29 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package ironhack;
import com.google.gson.Gson;
import ironhack.Orders.Order;
public class OrderProcessor {
static void main() {
System.out.println(readAndReturn());
}
public static Order readAndReturn() {
String exampleData = """
{
"orderId": "ORD-1001",
"customer": "John Doe",
"items": [
{
"productName": "Wireless Mouse",
"price": 25.50
},
{
"productName": "Mechanical Keyboard",
"price": 80.00
}
]
}
""";
Gson json = new Gson().newBuilder().setPrettyPrinting().create();
Order order = json.fromJson(exampleData, Order.class);
return order;
}
}