Back to project page ExampleApp.
The source code is released under:
Copyright (c) 2014, Altinn All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redis...
If you think the Android project ExampleApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.altinn.apps.fisher.net.jsobj; /**// w w w.j a va 2 s . co m * A JSONObject for "Forms" * Created into Java Object 'FormObj' to use their fields directly * */ import org.json.JSONException; import org.json.JSONObject; public class FormObj implements JsonObj{ public String mDataFormatId; public String mDataFormatVersion; public String mValidationStatus; public String mType; public String mName; public String mFormData; /* * (non-Javadoc) * @see com.altinn.apps.fisher.net.jsobj.JsonObj#parse(org.json.JSONObject) */ public FormObj parse(JSONObject jsObj){ FormObj obj = new FormObj(); try{ if(jsObj.has("DataFormatVersion")) obj.mDataFormatVersion = jsObj.getString("DataFormatVersion"); if(jsObj.has("DataFormatId")) obj.mDataFormatId = jsObj.getString("DataFormatId"); if(jsObj.has("ValidationStatus")) obj.mValidationStatus = jsObj.getString("ValidationStatus"); if(jsObj.has("Type")) obj.mType = jsObj.getString("Type"); if(jsObj.has("Name")) obj.mName = jsObj.getString("Name"); if(jsObj.has("FormData")) obj.mFormData = jsObj.getString("FormData"); }catch(JSONException jse){ obj = null; }catch(Exception e){ obj = null; } return obj; } /** * its a warper function for, which will support String type input. */ public FormObj parse(String jsStrings) throws JSONException { JSONObject jsObj = new JSONObject(jsStrings); return parse(jsObj); } /* * (non-Javadoc) * @see com.altinn.apps.fisher.net.jsobj.JsonObj#createJson() */ public JSONObject createJson(){ JSONObject jsObj = null; try { jsObj = new JSONObject(); if(mDataFormatVersion != null) jsObj.put("DataFormatVersion", mDataFormatVersion); if(mDataFormatId != null) jsObj.put("DataFormatId", mDataFormatId); if(mValidationStatus != null) jsObj.put("ValidationStatus", mValidationStatus); if(mType != null) jsObj.put("Type", mType); if(mName != null) jsObj.put("Name", mName); if(mFormData != null) jsObj.put("FormData", mFormData); } catch (JSONException e) { jsObj = null; e.printStackTrace(); } return jsObj; } }