var emails = [
{ name: "Peter Pan", to: "[email protected]" },
{ name: "Molly", to: "[email protected]" },
{ name: "Forneria Marconi", to: "[email protected]" },
{ name: "Master <em>Sync</em>", to: "[email protected]" },
{ name: "Dr. <strong>Tech</strong> de Log", to: "[email protected]" },
{ name: "Don Corleone", to: "[email protected]" },
{ name: "Mc Chick", to: "[email protected]" },
{ name: "Donnie Darko", to: "[email protected]" },
{ name: "Quake The Net", to: "[email protected]" },
{ name: "Dr. Write", to: "[email protected]" }
];麻烦大大们帮帮忙!怎么用JS形成这类的格式在数组对象中!

解决方案 »

  1.   

    {属性名:属性值,属性名:属性值,……}这是JSON格式定义JS对象的写法。如:var person1 ={name:"Li",age:12};
    var person2 ={name:"Wa",age:23};
    var arr=[];
    arr.push(person1);
    arr.push(person2);
      

  2.   

    非常感谢楼上的兄弟。。但因为我的数据是从后台取得再返回前台JS。。不知怎么转换。JAVA的。
      

  3.   

    偶滴神啊!去网上下JSON的辅助类!当然你自己实现也行!
    http://www.json.org/java/index.html把这个页面第一个JSONObject.java考下来就行了!用法傻瓜化!不说了了!
      

  4.   

    1\new JSONObject()
    2\obj.put(key,value)
    3\obj.toString()