Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "elementaryProductId":1,
- "bonusMalus":30,
- "deductible":500,
- "comprehensive":1,
- "partial":0,
- "legacyPremium":130,
- "product":{
- "productId":2,
- "garage":"true",
- "constructionYear":1990,
- "region":"East",
- "dateOfBirthYoungest":"1983-06-22",
- "objectValue":25000,
- "type":"Car",
- "insuredObject":{
- "name":"Car",
- "ownersName":"Jovana",
- "mileage":300000,
- "engineCapacity":120
- },
- "salesProduct":{
- "salesProductId":3,
- "currency":"EUR",
- "contractStart":"2011-01-01",
- "contractEnd":"2012-01-01"
- },
- "productType":"Car"
- }
- },
- {
- "elementaryProductId":1,
- "bonusMalus":5,
- "deductible":100,
- "comprehensive":1,
- "partial":0,
- "legacyPremium":75.38,
- "product":{
- "productId":2,
- "garage":"true",
- "constructionYear":2005,
- "region":"East",
- "dateOfBirthYoungest":"1999-06-22",
- "objectValue":30000,
- "type":"Car",
- "insuredObject":{
- "name":"Car",
- "ownersName":"Jelena",
- "mileage":300000,
- "engineCapacity":210
- },
- "salesProduct":{
- "salesProductId":3,
- "currency":"EUR",
- "contractStart":"2013-01-01",
- "contractEnd":"2014-01-01"
- },
- "productType":"Car"
- }
- },
- {
- "elementaryProductId":1,
- "bonusMalus":-8,
- "deductible":0,
- "comprehensive":1,
- "partial":0,
- "legacyPremium":111,
- "product":{
- "productId":2,
- "garage":"true",
- "constructionYear":1987,
- "region":"East",
- "dateOfBirthYoungest":"1977-09-22",
- "objectValue":4000,
- "type":"Car",
- "insuredObject":{
- "name":"Car",
- "ownersName":"Jelena",
- "mileage":300000,
- "engineCapacity":120
- },
- "salesProduct":{
- "salesProductId":3,
- "currency":"EUR",
- "contractStart":"2012-01-01",
- "contractEnd":"2013-01-01"
- },
- "productType":"Car"
- }
- },
- {
- "elementaryProductId":1,
- "bonusMalus":0,
- "deductible":0,
- "comprehensive":1,
- "partial":0,
- "legacyPremium":50,
- "product":{
- "productId":2,
- "garage":"true",
- "constructionYear":1999,
- "region":"East",
- "dateOfBirthYoungest":"1942-10-22",
- "objectValue":15000,
- "type":"Car",
- "insuredObject":{
- "name":"Car",
- "ownersName":"Bojana",
- "mileage":300000,
- "engineCapacity":160
- },
- "salesProduct":{
- "salesProductId":3,
- "currency":"DIN",
- "contractStart":"2012-01-01",
- "contractEnd":"2013-01-01"
- },
- "productType":"Car"
- }
- },
- {
- "elementaryProductId":1,
- "bonusMalus":0,
- "deductible":1000,
- "comprehensive":1,
- "partial":0,
- "legacyPremium":70,
- "product":{
- "productId":2,
- "garage":"false",
- "constructionYear":2011,
- "region":"East",
- "dateOfBirthYoungest":"1967-12-22",
- "objectValue":10000,
- "type":"Car",
- "insuredObject":{
- "name":"Car",
- "ownersName":"Tamara",
- "mileage":55000,
- "engineCapacity":70
- },
- "salesProduct":{
- "salesProductId":3,
- "currency":"EUR",
- "contractStart":"2012-01-01",
- "contractEnd":"2013-01-01"
- },
- "productType":"Car"
- }
- },
- {
- "elementaryProductId":1,
- "bonusMalus":-15,
- "deductible":1500,
- "comprehensive":1,
- "partial":0,
- "legacyPremium":130,
- "product":{
- "productId":2,
- "garage":"true",
- "constructionYear":1970,
- "region":"West",
- "dateOfBirthYoungest":"1952-06-22",
- "objectValue":35000,
- "type":"Car",
- "insuredObject":{
- "name":"Car",
- "ownersName":"Tijana",
- "mileage":15000,
- "engineCapacity":110
- },
- "salesProduct":{
- "salesProductId":3,
- "currency":"EUR",
- "contractStart":"2011-01-01",
- "contractEnd":"2012-01-01"
- },
- "productType":"Car"
- }
- },
- {
- "elementaryProductId":1,
- "bonusMalus":-2,
- "deductible":1500,
- "comprehensive":1,
- "partial":0,
- "legacyPremium":120,
- "product":{
- "productId":2,
- "garage":"true",
- "constructionYear":2003,
- "region":"East",
- "dateOfBirthYoungest":"1964-06-22",
- "objectValue":60000,
- "type":"Car",
- "insuredObject":{
- "name":"Car",
- "ownersName":"Dubravka",
- "mileage":300000,
- "engineCapacity":110
- },
- "salesProduct":{
- "salesProductId":3,
- "currency":"EUR",
- "contractStart":"2014-01-01",
- "contractEnd":"2015-01-01"
- },
- "productType":"Car"
- }
- },
- {
- "elementaryProductId":1,
- "bonusMalus":0,
- "deductible":0,
- "comprehensive":1,
- "partial":0,
- "legacyPremium":130,
- "product":{
- "productId":2,
- "garage":"false",
- "constructionYear":2013,
- "region":"East",
- "dateOfBirthYoungest":"1988-06-12",
- "objectValue":13000,
- "type":"Car",
- "insuredObject":{
- "name":"Car",
- "ownersName":"Tanja",
- "mileage":0,
- "engineCapacity":75
- },
- "salesProduct":{
- "salesProductId":3,
- "currency":"EUR",
- "contractStart":"2013-01-01",
- "contractEnd":"2014-01-01"
- },
- "productType":"Car"
- }
- }
- ]
- public class SalesProductClass {
- private int salesProductId;
- private String currency;
- private Date contractStart;
- private Date contractEnd;
- // getters & setters methods
- }
- public class InsuredClass {
- private String name;
- private String ownersName;
- private int mileage;
- private int engineCapacity;
- // getters & setters methods
- }
- public class ProductClass {
- private int productId;
- private String garage;
- private int constructionYear;
- private String region;
- private Date dateOfBirthYoungest;
- private int objectValue;
- private String type;
- private InsuredClass insuredObject;
- private SalesProductClass salesProduct;
- private String productType;
- // getters & setters methods
- }
- public class SomeRootClass {
- private int elementaryProductId;
- private int bonusMalus;
- private int deductible;
- private int comprehensive;
- private int partial;
- private int legacyPremium;
- private ProductClass product;
- // getters & setters methods
- }
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>2.3</version>
- </dependency>
- Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
- TypeToken<List<SomeRootClass>> token = new TypeToken<List<SomeRootClass>>() {};
- List<SomeRootClass> funds = gson.fromJson(jsonData, token.getType());
- public String readJsonFile(String fileNamePath) {
- BufferedReader br = null;
- String line = "";
- String data = "";
- try {
- br = new BufferedReader(new FileReader(fileNamePath));
- while ((line = br.readLine()) != null) {
- data += line;
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- try {
- if (br != null) {
- br.close();
- }
- } catch (Exception e2) {
- e2.printStackTrace();
- }
- }
- return data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement