From 7d8713e88c7872b195f7e4d02ac4812536ae196b Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Tue, 22 Sep 2015 13:53:51 +0000
Subject: [PATCH] #2756 feature - Added lic activation using activationCode

---
 src/main/java/net/curisit/securis/utils/JsonUtils.java |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/main/java/net/curisit/securis/utils/JsonUtils.java b/src/main/java/net/curisit/securis/utils/JsonUtils.java
index c71301d..7658d87 100644
--- a/src/main/java/net/curisit/securis/utils/JsonUtils.java
+++ b/src/main/java/net/curisit/securis/utils/JsonUtils.java
@@ -135,6 +135,26 @@
     }
 
     /**
+     * Create a JSON string from a object compatible or annotated with Jackson,
+     * i.e: <code>
+     * {"f1":2345,"f2":"Test de valor"}
+     * 
+     * @param obj
+     * @return JSON string representation from object
+     */
+    public static String toPrettyJSON(Object obj, Class<?> klass) throws SeCurisException {
+        // and could also do other configuration...
+        try {
+            if (obj == null)
+                return null;
+            return MAPPER_PRETTY.writerWithType(klass).writeValueAsString(obj);
+        } catch (IOException e) {
+            LOG.error("Error formating JSON from object: {}", obj, e);
+            throw new SeCurisException("Error formating JSON from object: " + obj, e);
+        }
+    }
+
+    /**
      * Create a Map from a json string, i.e: <code>
      * {"f1":2345,"f2":"Test de valor"}
      * </code>

--
Gitblit v1.3.2