• jquery 为json格式的数据进行排序


    一般得到的json格式的数据为:

    var newRankList=new Array();

    newRankList.put({"name":"aaa","password":"123","Id":"1"});

    newRankList.put({"name":"bbb","password":"456","Id":"2"});

    newRankList.put({"name":"ccc","password":"789","Id":"3"});

    按照Id进行排序:

    newRankList.sort(function (a,b){return a.Id-b.Id;});

    操作jquery中的json数据:

    数据:

    var data={"status":0,

    "data":{
      "rw":{
      "7075":      {"name":"\u5c0f\u4f1f\u4ed4","vip_level":"X","union_name":"\u5929\u5730\u4f1a","level":"XX","renown":"XXXX","ticket":"0","sum_fpower":"X","trend":0,"rank":1},
      "7617":  {"name":"\u5b50\u6602","vip_level":"X","union_name":"\u5929\u5730\u4f1a","level":"XX","renown":"XXXX","ticket":"0","sum_fpower":"XXXXX","trend":0,"rank":2},
      "923":{"name":"\u8303\u5f0f\u4e4b\u9b42","vip_level":"XX","union_name":"\u96c7\u4f63\u519b","level":"XXX","renown":"XXXX","ticket":"0","sum_fpower":"XXXX","trend":0,"rank":3}}}}

    获取name的话: data.data.rw.name

    如果是循环的话可以
    var list=data.data.rw;

    for(var i in list)

    {

    var name=list[i].name;

    var level=list[i].level;

    }

  • 相关阅读:
    saltstack安装和配置
    puppet安装和配置
    mongodb使用
    mongdb安装
    redis数据类型
    redis安装
    memcached结合php以及memcache共享session
    yum安装的Apache的各种配置文件的位置
    memcached 基本操作
    memcached基本操作和语法
  • 原文地址:https://www.cnblogs.com/douqiumiao/p/2818139.html
Copyright © 2020-2023  润新知