diff --git a/sm/apps/json2matlab.c b/sm/apps/json2matlab.c
index 05d109cb7f229e6e66cde826ee72f89e70aff1a8..e24941e5fcfaa194924cf82bb9071c772ca14df9 100644
--- a/sm/apps/json2matlab.c
+++ b/sm/apps/json2matlab.c
@@ -128,7 +128,7 @@ void jo_write_as_matlab(JO jo, FILE*out) {
 			fprintf(out, "%d", json_object_get_int(jo));		
 			return;
 
-		case json_type_double:
+		case json_type_double: 
 			fprintf(out, "%lg", json_object_get_double(jo));		
 			return;
 		
diff --git a/sm/lib/json-c/json_object.c b/sm/lib/json-c/json_object.c
index 937c4c215e635fbe89861e5f4358c3d07c8779a0..b32740e8d6626103d3115760e5660ffad085a4f7 100644
--- a/sm/lib/json-c/json_object.c
+++ b/sm/lib/json-c/json_object.c
@@ -357,15 +357,23 @@ int json_object_get_int(struct json_object *this)
   }
 }
 
+const char *float_format = "%e";
+
+void json_set_float_format(const char*f) {
+    float_format = f;
+}
 
 /* json_object_double */
 
 static int json_object_double_to_json_string(struct json_object* this,
 					     struct printbuf *pb)
 {
+#define AC_BETTER_PRECISION
 #ifdef AC_BETTER_PRECISION
+//#warning json: Using better precision in printing floats
 	if( ((int) this->o.c_double) !=  this->o.c_double)
-		return sprintbuf(pb, "%25.18Lg", this->o.c_double);
+//		return sprintbuf(pb, "%g", this->o.c_double);
+	    return sprintbuf(pb, float_format, this->o.c_double);
 	else
 		return sprintbuf(pb, "%d.0", (int) this->o.c_double);
 #else
diff --git a/sm/lib/json-c/json_object.h b/sm/lib/json-c/json_object.h
index fe9c9fa88e3fe2e5a7abfe525314b4a5813cf363..1d589ca6a3de3c3107c2d54c1c1142baa3d09657 100644
--- a/sm/lib/json-c/json_object.h
+++ b/sm/lib/json-c/json_object.h
@@ -46,6 +46,9 @@ enum json_type {
 
 /* reference counting functions */
 
+
+
+
 /**
  * Increment the reference count of json_object
  * @param obj the json_object instance
@@ -307,4 +310,6 @@ extern struct json_object* json_object_new_string_len(const char *s, int len);
  */
 extern char* json_object_get_string(struct json_object *obj);
 
+extern void json_set_float_format(const char*f);
+
 #endif