I am trying to get a value from the json result which returned to my JavaScript via an RET call. Below is a JSON result of REST
{"self": "http://example.com/rest/api/2/project/MTS/role/10002", "name": " "{{" Id ": 10803," displayName ":" administrator "," type ":" id ":" id ":" id ": 10002," Description ":" A project role that represents administrators in a project "," actor ": [ ":" Atlasian-user-roll-actor "," name ":" admin "," avatar url ":" / secure / userwater? Size = small and avatar id = 10108 "}, {" id ": 10590, DisplayName ":" Jirra-Administrator "," Type ":" Atlasian-Group-Role-Actor "," Name ":" Cicero-Administrator "," Av "We are only required to bring the name of all the actors," "Tarryl": "/ secure / user avatar = size = small and avatar ID = 10123"}]} The script can help with
function getName () {var user; $ Ajax ({url: "/ rest / API / 2 / project / mits / roll / 10002", type: 'received', data type: 'jason', async: wrong, success: work (data) {user = data; }}); Return user; } The above script is not correct
Success function in , Use it
users = []; // You will store names here $ .each (data, functions, (i, actor) {if (actor.type === "Atlasian-user-role-actor") {users.push (actor.name) ;}}} In the user you will get actor name
If you wish, copy paste your JSON and you will obviously see that the 'data' Is an object and how to access it.
No comments:
Post a Comment