Boon Tutorial
Selected Reading
- Boon - Discussion
- Boon - Useful Resources
- Boon - Quick Guide
- Boon - @JsonProperty
- Boon - @JsonViews
- Boon - @JsonInclude
- Boon - @JsonIgnore
- Boon - Generating Date
- Boon - String To Date
- Boon - Long To Date
- Boon - From Map
- Boon - From Object
- Boon - Sources
- Boon - To Map
- Boon - To Object
- Boon - Environment Setup
- Boon - Overview
- Boon - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Boon - To Map
Boon - To Map
ObjectMapper class can also be used to parse a json to Map object instead of a POJO object.
Example
Following example is using ObjectMapper class to parse a JSON string to a Map Object.
import java.util.Map; import org.boon.json.JsonFactory; import org.boon.json.ObjectMapper; pubpc class BoonTester { pubpc static void main(String args[]) { ObjectMapper mapper = JsonFactory.create(); String jsonString = "{"name":"Mahesh", "age":21}"; Map studentMap = mapper.readValue(jsonString, Map.class); System.out.println("Name: " + studentMap.get("name")); System.out.println("Age: " + studentMap.get("age")); } }
Output
The output is given below −
Name: Mahesh Age: 21Advertisements