commit a0511590bd585b69a2db164652e672725c938fe9
Author: @havlijan17 <havlijan@students.zcu.cz>
Date:   Wed Apr 15 17:50:27 2020 +0200

    #re#7831 Indetation problems. toString left, new toJson method
    Not working yet

diff --git a/project/Deserializer/bcha.json b/project/Deserializer/bcha.json
index 86cf9cf..82c2421 100644
--- a/project/Deserializer/bcha.json
+++ b/project/Deserializer/bcha.json
@@ -2,12 +2,12 @@
 	class samples.ok.Simple : {
 		"testDouble" : 1.0, 
 		"testInt" : 123, 
-		"intArray" : [ 5, 10, 15 ], 
+		"intArray" : [  ], 
 		"locInnerClassInstance" : {
-			class samples.ok.Inner : {
-				"vnitrni" : "INNER STRING AM I"
-			}
-		}, 
+		class samples.ok.Inner : {
+			"vnitrni" : "INNER STRING AM I"
+		}
+}, 
 		"localEnum" : LOW, 
 		"pozdrav" : "AHOJ", 
 		"stringArray" : [ "A", "B", "C" ]
diff --git a/project/Deserializer/src/Converter.java b/project/Deserializer/src/Converter.java
index 1b6ffc3..c1c52b7 100644
--- a/project/Deserializer/src/Converter.java
+++ b/project/Deserializer/src/Converter.java
@@ -59,14 +59,14 @@ public class Converter extends Thread {
 			{
 				if(cnt != null)
 				{
-					json += cnt.toString();
+					json += cnt.toJson("");
 				}
 			}
 
 			System.out.println("Task completed.");
 			
 			//just for tests
-			//System.out.println(json);
+			System.out.println(json);
 			
 			return json;
 		} catch (IOException e) {
diff --git a/project/Deserializer/src/jdeserialize/arrayobj.java b/project/Deserializer/src/jdeserialize/arrayobj.java
index cf13616..d5311b4 100644
--- a/project/Deserializer/src/jdeserialize/arrayobj.java
+++ b/project/Deserializer/src/jdeserialize/arrayobj.java
@@ -1,11 +1,16 @@
 package jdeserialize;
 
 /**
- * <p>Represents an array instance, including the values the comprise the array.  </p>
+ * <p>
+ * Represents an array instance, including the values the comprise the array.
+ * </p>
  *
- * <p>Note that in arrays of primitives, the classdesc will be named "[x", where x is the
- * field type code representing the primitive type.  See jdeserialize.resolveJavaType()
- * for an example of analysis/generation of human-readable names from these class names.</p>
+ * <p>
+ * Note that in arrays of primitives, the classdesc will be named "[x", where x
+ * is the field type code representing the primitive type. See
+ * jdeserialize.resolveJavaType() for an example of analysis/generation of
+ * human-readable names from these class names.
+ * </p>
  */
 public class arrayobj extends contentbase {
     /**
@@ -24,19 +29,26 @@ public class arrayobj extends contentbase {
         this.classdesc = cd;
         this.data = data;
     }
-    public String toString() {
+
+    public @Override String toJson(String indentation) {
         StringBuilder sb = new StringBuilder();
         sb.append("[ ");
-        for(Object el : this.data)
-        {
-            sb.append(el.toString());
-            if(!el.equals(this.data.get(this.data.size()-1)))
-            {
-                sb.append(", ");
+
+        for (Object el : this.data) {
+            if (el != null && el instanceof content) {
+                sb.append(((content)el).toJson(indentation));
+                // el null!
+                if (!el.equals(this.data.get(this.data.size() - 1))) {
+                    sb.append(", ");
+                }
             }
         }
         sb.append(" ]");
         return sb.toString();
     }
-}
 
+    public String toString() {
+        return "[array " + jdeserialize.hex(handle) + " classdesc " + classdesc.toString() + ": " + data.toString()
+                + "]";
+    }
+}
diff --git a/project/Deserializer/src/jdeserialize/content.java b/project/Deserializer/src/jdeserialize/content.java
index 1219de6..be81bb0 100644
--- a/project/Deserializer/src/jdeserialize/content.java
+++ b/project/Deserializer/src/jdeserialize/content.java
@@ -64,5 +64,7 @@ public interface content {
      * @param value the new value to use
      */
     public void setIsExceptionObject(boolean value);
+
+    public String toJson(String indentation);
 }
 
diff --git a/project/Deserializer/src/jdeserialize/contentbase.java b/project/Deserializer/src/jdeserialize/contentbase.java
index 0d429c8..2eb7bfb 100644
--- a/project/Deserializer/src/jdeserialize/contentbase.java
+++ b/project/Deserializer/src/jdeserialize/contentbase.java
@@ -24,5 +24,10 @@ public class contentbase implements content {
     }
     public void validate() throws ValidityException {
     }
+
+    public @Override String toJson(String indetation)
+    {
+        return this.toString();
+    }
 }
 
diff --git a/project/Deserializer/src/jdeserialize/enumobj.java b/project/Deserializer/src/jdeserialize/enumobj.java
index 16b15e5..89d6173 100644
--- a/project/Deserializer/src/jdeserialize/enumobj.java
+++ b/project/Deserializer/src/jdeserialize/enumobj.java
@@ -31,7 +31,11 @@ public class enumobj extends contentbase {
         this.classdesc = cd;
         this.value = so;
     }
-    public String toString() {
+    public @Override String toJson(String indetation) {
         return this.value.value;
     }
+
+    public String toString(){
+        return "[enum " + jdeserialize.hex(handle) + ": " + value.value + "]";
+    }
 }
diff --git a/project/Deserializer/src/jdeserialize/instance.java b/project/Deserializer/src/jdeserialize/instance.java
index 1ec2539..32490b6 100644
--- a/project/Deserializer/src/jdeserialize/instance.java
+++ b/project/Deserializer/src/jdeserialize/instance.java
@@ -26,11 +26,18 @@ public class instance extends contentbase {
         this.fielddata = new HashMap<classdesc, Map<field, Object>>();
     }
 
-    public String toString() {
+    public @Override String toJson(String indentation)
+    {
         StringBuffer sb = new StringBuffer();
+        String val = "";
+
+        /*if (classdesc.getType() == contenttype.CLASSDESC && !instance.indentedClasses.contains(classdesc.name)) {*/
+            indentation += "\t";
+           /* instance.indentedClasses.add(classdesc.name);
+        }*/
 
         // ClassName
-        sb.append("{\n\tclass ").append(classdesc.name);
+        sb.append("{\n").append(indentation).append("class ").append(classdesc.name);
         // extends
         if (classdesc.superclass != null) {
             sb.append(" extends ").append(classdesc.superclass.name);
@@ -48,10 +55,19 @@ public class instance extends contentbase {
             // v this.fielddata najit element, jehoz key == classdesc
             // v tomto prvku fielddata najdu value (element) podle key == f
             // jeho value je chtena hodnota
-            var val = this.fielddata.get(classdesc).get(f).toString();
-            sb.append("\n\t\t");
-            // Datový typ není potřeba - json jej nepoužívá!
-            sb.append("\"")./* append(f.type.getJavaType()).append(" "). */append(f.name).append("\"");
+            
+            var locVal = this.fielddata.get(classdesc).get(f);
+
+            if(locVal instanceof content)
+            {
+                val = ((content)locVal).toJson(indentation);
+            }
+            else {
+                val = locVal.toString();
+            }
+
+            sb.append("\n\t").append(indentation);
+            sb.append("\"").append(f.name).append("\"");
             sb.append(" : ");
             sb.append(val);
 
@@ -60,8 +76,21 @@ public class instance extends contentbase {
             }
         }
 
-        sb.append("\n\t}\n}");
+        sb.append("\n").append(indentation).append("}\n}");
 
+        /*if (classdesc.getType() == contenttype.CLASSDESC && instance.indentedClasses.contains(classdesc.name)) {*/
+            indentation.replaceFirst("\t", "");
+            /*instance.indentedClasses.remove(classdesc.name);
+        }*/
+
+        return sb.toString();
+    }
+
+    public String toString() {
+        StringBuffer sb = new StringBuffer();
+        sb.append(classdesc.name).append(' ').append("_h").append(jdeserialize.hex(handle))
+            .append(" = r_").append(jdeserialize.hex(classdesc.handle)).append(";  ");
+        //sb.append("// [instance " + jdeserialize.hex(handle) + ": " + jdeserialize.hex(classdesc.handle) + "/" + classdesc.name).append("]");
         return sb.toString();
     }
 
diff --git a/project/Deserializer/src/jdeserialize/jdeserialize.java b/project/Deserializer/src/jdeserialize/jdeserialize.java
index d4fcabd..4d57c73 100644
--- a/project/Deserializer/src/jdeserialize/jdeserialize.java
+++ b/project/Deserializer/src/jdeserialize/jdeserialize.java
@@ -837,7 +837,7 @@ public class jdeserialize {
                     break;
                 }
                 content c = read_Content(tc, dis, true);
-                System.out.println("read: " + c.toString());
+                //System.out.println("read: " + c.toString());
                 if(c != null && c.isExceptionObject()) {
                     c = new exceptionstate(c, lis.getRecordedData());
                 }
diff --git a/project/Deserializer/src/jdeserialize/stringobj.java b/project/Deserializer/src/jdeserialize/stringobj.java
index 7634520..a464680 100644
--- a/project/Deserializer/src/jdeserialize/stringobj.java
+++ b/project/Deserializer/src/jdeserialize/stringobj.java
@@ -15,9 +15,15 @@ public class stringobj extends contentbase {
         }
         return x;
     }
-    public String toString() {
+
+    public @Override String toJson(String indetation)
+    {
         return "\"" + this.value + "\"";
     }
+
+    public String toString() {
+        return "[String " + jdeserialize.hex(handle) + ": \"" + value + "\"]";
+    }
     /**
      * Constructor.
      *
