public IValue visitMap(IMap o) throws IOException {
Iterator<IValue> mapIterator = o.iterator();
if (o.getKeyType().isString()) {
append('{');
if (mapIterator.hasNext()) {
IValue key = mapIterator.next();
key.accept(this);
append(':');
o.get(key).accept(this);
while (mapIterator.hasNext()) {
append(',');
key = mapIterator.next();
key.accept(this);
append(':');
o.get(key).accept(this);
}
}
append('}');
} else {
if (typed || inNode > 0)
append("{\"" + name + "\":\"#map\",\"" + args + "\":[");
else
append('[');
if (mapIterator.hasNext()) {
if (typed || inNode > 0)
append("{\"" + name + "\":\"#tuple\",\"" + args
+ "\":[");
else
append('[');
IValue key = mapIterator.next();
key.accept(this);
append(',');
o.get(key).accept(this);
if (typed || inNode > 0)
append("]}");
else
append(']');
while (mapIterator.hasNext()) {
append(',');
if (typed || inNode > 0)
append("{\"" + name + "\":\"#tuple\",\"" + args
+ "\":[");
else
append('[');
key = mapIterator.next();
key.accept(this);
append(',');
o.get(key).accept(this);
if (typed || inNode > 0)
append("]}");
else