Search in sources :

Example 1 with JSONSerializerWrapper

use of com.servoy.j2db.util.serialize.JSONSerializerWrapper in project servoy-client by Servoy.

the class FoundSetManager method replaceValuesWithSerializedString.

private static void replaceValuesWithSerializedString(IDataSet dataSet, boolean[] rowsToStringserialize) {
    // run stringserializer over the rows
    JSONSerializerWrapper stringserializer = new JSONSerializerWrapper(false);
    for (int r = 0; r < dataSet.getRowCount(); r++) {
        Object[] row = dataSet.getRow(r).clone();
        for (int i = 0; i < rowsToStringserialize.length; i++) {
            if (rowsToStringserialize[i] && row[i] != null && !(row[i] instanceof String)) {
                // the data was not a string (so not pre-serialized from js), run it through the stringserializer.
                try {
                    row[i] = stringserializer.toJSON(row[i]).toString();
                } catch (MarshallException e) {
                    Debug.warn(e);
                }
            }
        }
        dataSet.setRow(r, row);
    }
}
Also used : JSONSerializerWrapper(com.servoy.j2db.util.serialize.JSONSerializerWrapper) MarshallException(org.jabsorb.serializer.MarshallException) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject)

Example 2 with JSONSerializerWrapper

use of com.servoy.j2db.util.serialize.JSONSerializerWrapper in project servoy-client by Servoy.

the class FoundSetManager method replaceValuesWithSerializedString.

private static void replaceValuesWithSerializedString(IDataSet dataSet, Set<Integer> columnsThatNeedToStringSerialize) {
    Integer[] colIndexesThatNeedToStringSerialize = columnsThatNeedToStringSerialize.toArray(new Integer[columnsThatNeedToStringSerialize.size()]);
    // run stringserializer over the rows
    JSONSerializerWrapper stringserializer = new JSONSerializerWrapper(false);
    for (int r = 0; r < dataSet.getRowCount(); r++) {
        Object[] row = dataSet.getRow(r).clone();
        for (Integer colIdxAsInteger : colIndexesThatNeedToStringSerialize) {
            int colIdx = colIdxAsInteger.intValue();
            if (row[colIdx] != null && !(row[colIdx] instanceof String)) {
                // the data was not a string (so not pre-serialized from js), run it through the stringserializer.
                try {
                    row[colIdx] = stringserializer.toJSON(row[colIdx]).toString();
                } catch (MarshallException e) {
                    Debug.warn(e);
                }
            }
        }
        dataSet.setRow(r, row);
    }
}
Also used : JSONSerializerWrapper(com.servoy.j2db.util.serialize.JSONSerializerWrapper) MarshallException(org.jabsorb.serializer.MarshallException) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject)

Aggregations

ServoyJSONObject (com.servoy.j2db.util.ServoyJSONObject)2 JSONSerializerWrapper (com.servoy.j2db.util.serialize.JSONSerializerWrapper)2 MarshallException (org.jabsorb.serializer.MarshallException)2