3 Replies Latest reply on Jun 6, 2011 5:57 AM by Owain North

    coldfusion.runtime.Array vs java.lang.Object

    Owain North Level 4

      Is there any way of casting between these two? I'm trying to write a component in cfscript which involves validating an Xml document against a schema. All the validation itself works fine, and xmlValidate returns a struct which contains two array properties; "Errors" and "FatalErrors".

       

      Much as they look like arrays, isArray() returns true, cfdump shows them as arrays, they're not; it's this old gem where behind the scenes CF has created them in some crazy internal way which means they're different.

       

      var myArr = ["value1", "value2"] ;

      writeoutput("myArr.getClass(): " & myArr.getClass()) ;

           myArr.getClass(): class coldfusion.runtime.Array

       

      var ValidationErrors = xmlValidate(TextContent, SchemaFile) ;

      writeoutput("ValidationErrors.Errors.getClass(): " & ValidationErrors.Errors.getClass()) ;

           ValidationErrors.Errors.getClass(): class [Ljava.lang.Object;

       

      The upshot being that I cannot use the new 9.01 syntax for looping over an array, ie the "for ( var i in ValidationErrors.Errors )". I hate having to write my code around bugs, so does anyone know if there's a way round? Or am I doomed?

       

      Ta.