Index: /cpp/frams/param/param.cpp
===================================================================
--- /cpp/frams/param/param.cpp	(revision 463)
+++ /cpp/frams/param/param.cpp	(revision 464)
@@ -296,5 +296,5 @@
 		ExtValue ex;
 		get(i, ex);
-		ws = SString(SERIALIZATION_PREFIX) + ex.serialize();
+		ws = SString(SERIALIZATION_PREFIX) + ex.serialize(NativeSerialization);
 	}
 	else
Index: /cpp/frams/util/extvalue.cpp
===================================================================
--- /cpp/frams/util/extvalue.cpp	(revision 463)
+++ /cpp/frams/util/extvalue.cpp	(revision 464)
@@ -183,17 +183,30 @@
 }
 
-SString ExtObject::serialize_inner() const
+SString ExtObject::serialize_inner(SerializationFormat format) const
 {
 	int ref = tlsGetRef(ExtObject_serialization).add(*this);
+	SString ret;
+
 	if (ref >= 0)
-		return SString::sprintf("^%d", ref);
+		{
+		switch(format)
+			{
+			case NativeSerialization: return SString::sprintf("^%d", ref);
+			case JSONSerialization: return SString("null");
+			}
+		}
 
 	if (isEmpty()) return SString("null");
+	{
 	VectorObject *vec = VectorObject::fromObject(*this, false);
 	if (vec)
-		return vec->serialize();
+		{ ret=vec->serialize(format); goto finally; }
+	}
+	{
 	DictionaryObject *dic = DictionaryObject::fromObject(*this, false);
 	if (dic)
-		return dic->serialize();
+		{ ret=dic->serialize(format); goto finally; }
+	}
+	{
 	Param tmp_param;
 	ParamInterface *p = getParamInterface(tmp_param);
@@ -204,6 +217,10 @@
 	{
 		ExtObject o(p->getObject(m));
-		SString ret = SString(interfaceName()) + o.serialize();
-		return ret;
+		switch(format)
+			{
+			case NativeSerialization: ret=SString(interfaceName())+o.serialize(format); break;
+			case JSONSerialization: ret=SString::sprintf("{\"class\":\"%s\",\"data\":%s}",interfaceName(),o.serialize(format).c_str()); break;
+			}
+		goto finally;
 	}
 	m = p->findId("toString");
@@ -212,18 +229,36 @@
 		SString str = p->getString(m);
 		sstringQuote(str);
-		SString ret = SString(interfaceName()) + "\"" + str + "\"";
-		return ret;
+		switch(format)
+			{
+			case NativeSerialization: ret=SString(interfaceName())+"\"" +str+"\""; break;
+			case JSONSerialization: ret=SString::sprintf("{\"class\":\"%s\",\"data\":\"%s\"}",interfaceName(),str.c_str()); break;
+			}
+		goto finally;
+	}
 	}
 
 	tlsGetRef(ExtObject_serialization).remove(*this);//undo nonserializable reference
-	SString ret = interfaceName();
-	ret += SString::sprintf("<%p>", object ? object : paraminterface);
+	switch(format)
+		{
+		case NativeSerialization: return SString(interfaceName())+SString::sprintf("<%p>",object ? object : paraminterface); break;
+		case JSONSerialization: return SString::sprintf("{\"class\":\"%s\"}",interfaceName()); break;
+		}
+
+  finally: // not 100% "finally", the case of nonserializable reference (directly above) returns directly without going through finally
+
+	switch(format)
+		{
+		case JSONSerialization: 
+			tlsGetRef(ExtObject_serialization).remove(*this);//JSON only tracks recursion, does not track reuse
+			break;
+		}
+
 	return ret;
 }
 
-SString ExtObject::serialize() const
+SString ExtObject::serialize(SerializationFormat format) const
 {
 	tlsGetRef(ExtObject_serialization).begin();
-	SString ret = serialize_inner();
+	SString ret = serialize_inner(format);
 	tlsGetRef(ExtObject_serialization).end();
 	return ret;
@@ -874,5 +909,5 @@
 }
 
-SString ExtValue::serialize() const
+SString ExtValue::serialize(SerializationFormat format) const
 {
 	switch (type)
@@ -889,7 +924,9 @@
 		return SString::valueOf(ddata());
 	case TObj:
-		return odata().serialize();
+		return odata().serialize(format);
 	case TInvalid:
-		return SString("invalid");
+		if (format==NativeSerialization)
+			return SString("invalid");
+		// else null --v
 	default:
 		return SString("null");
Index: /cpp/frams/util/extvalue.h
===================================================================
--- /cpp/frams/util/extvalue.h	(revision 463)
+++ /cpp/frams/util/extvalue.h	(revision 464)
@@ -32,4 +32,6 @@
 	virtual ~DestrBase() {}
 };
+
+enum SerializationFormat { NativeSerialization, JSONSerialization };
 
 /**
@@ -75,6 +77,6 @@
 
 	SString toString() const;
-	SString serialize_inner() const;
-	SString serialize() const;
+	SString serialize_inner(SerializationFormat format) const;
+	SString serialize(SerializationFormat format) const;
 
 	ExtObject(Param *p, void *o) :subtype(2), object(o), param(p){}
@@ -194,5 +196,5 @@
 	SString getString() const;
 	const SString* getStringPtr() const;//< @return pointer to the internal sstring object or NULL if the current type is not string
-	SString serialize() const;
+	SString serialize(SerializationFormat format) const;
 	ExtObject getObject() const;
 	bool isNull() const { return (type == TUnknown) || ((type == TObj) && odata().isEmpty()); }
Index: /cpp/frams/vm/classes/collectionobj.cpp
===================================================================
--- /cpp/frams/vm/classes/collectionobj.cpp	(revision 463)
+++ /cpp/frams/vm/classes/collectionobj.cpp	(revision 464)
@@ -154,5 +154,5 @@
 }
 
-SString VectorObject::serialize() const
+SString VectorObject::serialize(SerializationFormat format) const
 {
 SString out="[";
@@ -163,5 +163,5 @@
 		if (i) out+=",";
 		if (v)
-			out+=v->serialize();
+			out+=v->serialize(format);
 		else
 			out+="null";
@@ -413,5 +413,5 @@
 }
 
-SString DictionaryObject::serialize() const
+SString DictionaryObject::serialize(SerializationFormat format) const
 {
 SString out="{";
@@ -424,5 +424,5 @@
 		out+="\":";
 		if (it->value!=NULL)
-			out+=((ExtValue*)it->value)->serialize();
+			out+=((ExtValue*)it->value)->serialize(format);
 		else
 			out+="null";
Index: /cpp/frams/vm/classes/collectionobj.h
===================================================================
--- /cpp/frams/vm/classes/collectionobj.h	(revision 463)
+++ /cpp/frams/vm/classes/collectionobj.h	(revision 464)
@@ -42,5 +42,5 @@
 static void p_new(void*,ExtValue*args,ExtValue*ret)
 	{ret->setObject(ExtObject(&par,new VectorObject));}
-SString serialize() const;
+SString serialize(SerializationFormat format) const;
 ExtObject makeObject() {return ExtObject(&par,this);}
 
@@ -73,5 +73,5 @@
 PARAMPROCDEF(p_clone);
 #undef STATRICKCLASS
-SString serialize() const;
+SString serialize(SerializationFormat format) const;
 static void p_new(void*,ExtValue*args,ExtValue*ret)
 	{ret->setObject(ExtObject(&par,new DictionaryObject));}
