Example usage for com.liferay.portal.kernel.json JSONFactoryUtil looseSerializeDeep

List of usage examples for com.liferay.portal.kernel.json JSONFactoryUtil looseSerializeDeep

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.json JSONFactoryUtil looseSerializeDeep.

Prototype

public static String looseSerializeDeep(Object object) 

Source Link

Usage

From source file:com.liferay.screens.service.impl.ScreensDDMStructureVersionServiceImpl.java

License:Open Source License

@Override
public JSONObject getDDMStructureVersion(long structureId) throws PortalException {

    JSONObject ddmStructureVersionJSONObject = JSONFactoryUtil.createJSONObject();

    DDMStructureVersion ddmStructureVersion = ddmStructureVersionService.getLatestStructureVersion(structureId);

    DDMFormLayout ddmFormLayout = ddmStructureVersion.getDDMFormLayout();

    JSONObject ddmFormLayoutJSONObject = JSONFactoryUtil
            .createJSONObject(JSONFactoryUtil.looseSerializeDeep(ddmFormLayout));

    ddmStructureVersionJSONObject.put("ddmFormLayout", ddmFormLayoutJSONObject);

    JSONObject ddmStructureJSONObject = JSONFactoryUtil
            .createJSONObject(JSONFactoryUtil.looseSerialize(ddmStructureVersion.getStructure()));

    ddmStructureVersionJSONObject.put("ddmStructure", ddmStructureJSONObject);

    return ddmStructureVersionJSONObject;
}

From source file:com.liferay.sync.model.SyncDLObjectUpdateTest.java

License:Open Source License

@Test
public void testToString() {
    List<SyncDLObject> syncDLObjects = new ArrayList<>(3);

    SyncDLObject syncDLObject = new SyncDLObjectImpl();

    syncDLObject.setDescription("These values should be escaped: \", \\, \\b, \\f, \\n, \\r, \\t");
    syncDLObject.setLockExpirationDate(new Date());

    syncDLObjects.add(syncDLObject);/*from  www.  j a v  a 2s . com*/
    syncDLObjects.add(syncDLObject);
    syncDLObjects.add(syncDLObject);

    SyncDLObjectUpdate syncDLObjectUpdate = new SyncDLObjectUpdate(syncDLObjects, syncDLObjects.size(),
            System.currentTimeMillis());

    String expectedJSON = JSONFactoryUtil.looseSerializeDeep(syncDLObjectUpdate);

    String actualJSON = syncDLObjectUpdate.toString();

    Assert.assertEquals(expectedJSON.replace(StringPool.SPACE, StringPool.BLANK),
            actualJSON.replace(StringPool.SPACE, StringPool.BLANK));
}