Browse Source

fix issue 699

Franco Ponticelli 13 years ago
parent
commit
4bf99fc510
2 changed files with 18 additions and 4 deletions
  1. 11 1
      genphp.ml
  2. 7 3
      std/haxe/Json.hx

+ 11 - 1
genphp.ml

@@ -1719,11 +1719,21 @@ and gen_value ctx e =
 	| TTry _ ->
 		inline_block ctx e
 
+let rec is_instance_method_defined cls m =
+	if PMap.exists m cls.cl_fields then
+		true
+	else
+		match cls.cl_super with
+		| Some (scls, _) ->
+			is_instance_method_defined scls m
+		| None ->
+			false
+		
 let is_method_defined ctx m static =
 	if static then
 		PMap.exists m ctx.curclass.cl_statics
 	else
-		PMap.exists m ctx.curclass.cl_fields
+		is_instance_method_defined ctx.curclass m
 
 let generate_self_method ctx rights m static setter =
 	if setter then (

+ 7 - 3
std/haxe/Json.hx

@@ -327,7 +327,7 @@ class Json {
 	public static function parse( text : String ) : Dynamic {
 		#if (__php && !haxeJSON)
 		// don't use because of arrays wrappers
-		return untyped __call__("json_encode", value);
+		return untyped __call__("json_decode", value);
 		#elseif (flash11 && !haxeJSON)
 		return null;
 		#else
@@ -337,8 +337,12 @@ class Json {
 
 	public static function stringify( value : Dynamic ) : String {
 		#if (__php && !haxeJSON)
-		// don't use because of arrays wrappers
-		return untyped __call__("json_encode", value);
+		// slash behavior is incosistent with other platforms
+		var r = untyped __call__("json_encode", value);
+		if (untyped __physeq__(r, false))
+			return throw "invalid json";
+		else
+			return r;
 		#elseif (flash11 && !haxeJSON)
 		return null;
 		#else