How to get json key and value in javascript?

前端 未结 8 1352
暗喜
暗喜 2020-11-28 06:02

I am returning a json as shown below

{\"name\": \"\", \"skills\": \"\", \"jobtitel\": \"Entwickler\", \"res_linkedin\": \"GwebSearch\"}

I a

相关标签:
8条回答
  • 2020-11-28 06:26

    For getting key

    var a = {"a":"1","b":"2"};
    var keys = []
    for(var k in a){
      keys.push(k)
    }
    

    For getting value.

    var a = {"a":"1","b":"2"};
    var values = []
    for(var k in a){
      values.push(a[k]);
    }
    
    0 讨论(0)
  • 2020-11-28 06:27

    You can use the following solution to get a JSON key and value in JavaScript:

    var dt = JSON.stringify(data).replace('[', '').replace(']', '');
    if (dt) {
      var result = jQuery.parseJSON(dt);
      var val = result.YOUR_OBJECT_NAME;
    }
    
    0 讨论(0)
提交回复
热议问题