@Override public void setValue(String theValue) throws StandardException { // stream = null; rawLength = -1; // cKey = null; // value = theValue; if (theValue != null) { PdxInstance jsonPdxInstance1 = null; try { jsonPdxInstance1 = JSONFormatter.fromJSON(theValue); } catch (JSONFormatterException je) { //showing only first 255 chars of the input String s = theValue; if (theValue.length() > 255) { s = theValue.substring(0, 255); } throw StandardException.newException(SQLState.LANG_INVALID_JSON, je, s, 255); } jsonPdxInstanceBytes = ((PdxInstanceImpl) jsonPdxInstance1).toBytes(); } else { jsonPdxInstanceBytes = null; } this.rawData = null; }
@Override public void setValue(String theValue) throws StandardException { // stream = null; rawLength = -1; // cKey = null; // value = theValue; if (theValue != null) { PdxInstance jsonPdxInstance1 = null; try { jsonPdxInstance1 = JSONFormatter.fromJSON(theValue); } catch (JSONFormatterException je) { //showing only first 255 chars of the input String s = theValue; if (theValue.length() > 255) { s = theValue.substring(0, 255); } throw StandardException.newException(SQLState.LANG_INVALID_JSON, je, s, 255); } jsonPdxInstanceBytes = ((PdxInstanceImpl) jsonPdxInstance1).toBytes(); } else { jsonPdxInstanceBytes = null; } this.rawData = null; }
@Override public void setValue(String theValue) throws StandardException { // stream = null; rawLength = -1; // cKey = null; // value = theValue; if (theValue != null) { PdxInstance jsonPdxInstance1 = null; try { jsonPdxInstance1 = JSONFormatter.fromJSON(theValue); } catch (JSONFormatterException je) { //showing only first 255 chars of the input String s = theValue; if (theValue.length() > 255) { s = theValue.substring(0, 255); } throw StandardException.newException(SQLState.LANG_INVALID_JSON, je, s, 255); } jsonPdxInstanceBytes = ((PdxInstanceImpl) jsonPdxInstance1).toBytes(); } else { jsonPdxInstanceBytes = null; } this.rawData = null; }
public void VerifyJSONString(JSONData jd) { Region r = getRootRegion("testSimplePdx"); PdxInstance pdx = JSONFormatter.fromJSON(jd.getJsonString()); r.put(1, pdx); pdx = (PdxInstance)r.get(1); String getJsonString = JSONFormatter.toJSON(pdx); String o1 = jsonParse(jd.getJsonString()); String o2 = jsonParse(getJsonString); junit.framework.Assert.assertEquals("Json Strings are not equal " + jd.getFileName() + " " + Boolean.getBoolean("pdxToJson.unqouteFieldNames"), o1, o2); PdxInstance pdx2 = JSONFormatter.fromJSON(getJsonString); junit.framework.Assert.assertEquals("Pdx are not equal; json filename " + jd.getFileName(), pdx, pdx2); }
public PdxInstance toObject(String json) { JSONObject jsonObject = null; try { jsonObject = new JSONObject(json); } catch (JSONException e) { throw new MessageTransformationException(e.getMessage()); } return JSONFormatter.fromJSON(jsonObject.toString()); }
public void VerifyJSONByteArray(JSONData jd) { Region r = getRootRegion("testSimplePdx"); PdxInstance pdx = JSONFormatter.fromJSON(jd.getJsonByteArray()); r.put(1, pdx); pdx = (PdxInstance)r.get(1); byte[] jsonByteArray = JSONFormatter.toJSONByteArray(pdx); byte[] o1 = jsonParse(jd.getJsonByteArray()); byte[] o2 = jsonParse(jsonByteArray); // junit.framework.Assert.assertEquals("Pdx byte aray are not equal after fetching from cache " + jd.getFileName(), o1, o2); compareByteArray(o1, o2); PdxInstance pdx2 = JSONFormatter.fromJSON(jsonByteArray); boolean pdxequals = pdx.equals(pdx2); junit.framework.Assert.assertEquals("Pdx are not equal for byte array ; json filename " + jd.getFileName(), pdx, pdx2 ); } public void compareByteArray(byte[] b1, byte[] b2) {