JSON serializer fixes:

* removed call to sortChildrenList(), as it is no longer needed
* removed call to urlPathArgsDecode(), and deprecated the API

Change-Id: I12243cae30c8b6c4e16370dfe5055c67ec670fc9
diff --git a/serializers/json/src/main/java/org/onosproject/yang/serializers/json/EncoderUtils.java b/serializers/json/src/main/java/org/onosproject/yang/serializers/json/EncoderUtils.java
index 4a5148d..d69fed2 100644
--- a/serializers/json/src/main/java/org/onosproject/yang/serializers/json/EncoderUtils.java
+++ b/serializers/json/src/main/java/org/onosproject/yang/serializers/json/EncoderUtils.java
@@ -23,6 +23,7 @@
 import org.onosproject.yang.runtime.YangSerializerContext;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -110,9 +111,14 @@
         DataNodeSiblingPositionType prevChildType = UNKNOWN_TYPE;
         DataNodeSiblingPositionType currChildType = UNKNOWN_TYPE;
 
-        List<DataNode> sortedChildList = sortChildrenList(childrenList);
-        checkNotNull(sortedChildList, "sorted children list cannot be null");
-        Iterator<DataNode> it = sortedChildList.iterator();
+        /*
+         * Dynamic Config preserves the order of child nodes.
+         * So, we no longer need to sort the children.
+         */
+        //List<DataNode> sortedChildList = sortChildrenList(childrenList);
+        //checkNotNull(sortedChildList, "sorted children list cannot be null");
+        Collection<DataNode> dataNodeList = childrenList.values();
+        Iterator<DataNode> it = dataNodeList.iterator();
         DataNode currChild = it.next();
         DataNode nextChild = null;
         boolean lastChildNotProcessed = true;
diff --git a/serializers/utils/src/main/java/org/onosproject/yang/serializers/utils/SerializersUtil.java b/serializers/utils/src/main/java/org/onosproject/yang/serializers/utils/SerializersUtil.java
index 8cef511..bf463e2 100644
--- a/serializers/utils/src/main/java/org/onosproject/yang/serializers/utils/SerializersUtil.java
+++ b/serializers/utils/src/main/java/org/onosproject/yang/serializers/utils/SerializersUtil.java
@@ -40,6 +40,7 @@
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
@@ -57,6 +58,7 @@
     private static final String ROOT_ELEMENT_START = "<root ";
     private static final String ROOT_ELEMENT_END = "</root>";
     private static final String URI_ENCODING_CHAR_SET = "ISO-8859-1";
+    private static final String UTF8_ENCODING = "utf-8";
     private static final String ERROR_LIST_MSG = "List/Leaf-list node should be " +
             "in format \"nodeName=key\"or \"nodeName=instance-value\"";
     private static final String EQUAL = "=";
@@ -142,7 +144,8 @@
             return null;
         }
 
-        List<String> paths = urlPathArgsDecode(SLASH_SPLITTER.split(uriString));
+        //List<String> paths = urlPathArgsDecode(SLASH_SPLITTER.split(uriString));
+        List<String> paths = Arrays.asList(uriString.split(SLASH));
 
         if (!paths.isEmpty()) {
             ResourceId.Builder ridBuilder =
@@ -160,6 +163,7 @@
      * @param paths the original paths
      * @return list of decoded paths
      */
+    @Deprecated
     public static List<String> urlPathArgsDecode(Iterable<String> paths) {
         try {
             List<String> decodedPathArgs = new ArrayList<>();
@@ -263,18 +267,11 @@
 
 
     private static String uriDecodedString(String keyStr) {
-        /*
-         * replaceAll() may be an expensive operation. So, call
-         * contains() to determine if replaceAll() is really need
-         * to be invoked.
-         */
-        if (keyStr.contains(URI_ENCODED_SLASH)) {
-            keyStr = keyStr.replaceAll(URI_ENCODED_SLASH, SLASH);
+        try {
+            keyStr = URLDecoder.decode(keyStr, UTF8_ENCODING);
+        } catch (UnsupportedEncodingException ex) {
+            throw new SerializerUtilException("UnsupportedEncodingException: " + ex.getMessage());
         }
-        if (keyStr.contains(URI_ENCODED_COLON)) {
-            keyStr = keyStr.replaceAll(URI_ENCODED_COLON, COLON);
-        }
-        //TODO: need to decode other percentage encoded characters.
 
         return keyStr;
     }