Worklight Javascript Adapter: Unable to retrieve array value passed as parameter to adapter

I pass a array to the Worklight adapter, and I am unable to retrieve the value in my array.

Inside my -impl.js file, i create a function like:

function getlist(list) {
   ...
}

list is an array. And in my adapter, I try to output the value.

WL.Logger.info(list);
WL.Logger.info(list.arr);

It output like:

[INFO    ] {
"arr": [
   {
     "a": "...",
     "b": "..."
   },
   {
     "a": "...",
    "b": "..."
  },
  {
    "a": "...",
    "b": "..."
  },

   ]
} [project test]
[INFO    ] undefined [project test]

I just do not get it. list is first output, which is fine. However, list.arr is the second one and it says undefined. Why list.arr is undefined?

No idea what is wrong.

WL verison: 6.0.0.20130614-0631

Answers


Your list argument IS an array. However the output of a WL.Logger.*() must always be an object (mandated by underlying JS engine). So your array is converted to object for logging purposes. E.g. if your list object is

[1,2,3]

the WL.Logger.debug(list) will be

{ arr: [1,2,3] }

The original object is not modified, it will remain an array. You can still get elements with list[0], list[1] etc.


Need Your Help

Adding custom menu item to BlackBerry “documents to go” app

blackberry java-me

Is it possible to add a custom menu item, such as "print", that can perform my specific task in the "documents to go" application?

How to get a IStereotype reference in a T4 Template?

visual-studio-2010 profile extensibility uml stereotype

Is there a way to get a reference to Microsoft.VisualStudio.Uml.Profiles.IStereotype interface in a t4 template? I mean IStereotype that stores the definition of the UML stereotype, and not

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.