Solved

JSON question

Posted on 2014-11-09
2
152 Views
Last Modified: 2014-11-09
i,

If my returned JSON is of the format as mentioned below, how do i get the Value "Project.Description"? using JQuery?

                                               
REST Request

function getitems() {
    var url = "http://sc-spstd-dev.mysite.com/it/PM/_api/web/lists/getbytitle('IT Dashboard Project')/items?$filter=Id eq 39";
    $.ajax({
        url: url,
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            if (data.d.results.length == 1) {
                alert("success: " + data.d.results.Project.Description);

                $("#dataholder").html(JSON.stringify(data));
                //success(data.d.results[0]);
            }
            else {

                alert("failure: " + JSON.stringify(data));

                //failure("Multiple results obtained for the specified Id value");
            }
        },
        error: function (data) {
            //failure(data);
        }
    });
}
Returned JSON

{"d":{"results":[{"__metadata":{"id":"6455ed93-382f-404f-a5ee-8247306f4786","uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)","etag":"\"23\"","type":"SP.Data.IT_x0020_Dashboard_x0020_ProjectListItem"},"FirstUniqueAncestorSecurableObject":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/FirstUniqueAncestorSecurableObject"}},"RoleAssignments":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/RoleAssignments"}},"AttachmentFiles":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/AttachmentFiles"}},"ContentType":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/ContentType"}},"FieldValuesAsHtml":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/FieldValuesAsHtml"}},"FieldValuesAsText":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/FieldValuesAsText"}},"FieldValuesForEdit":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/FieldValuesForEdit"}},"File":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/File"}},"Folder":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/Folder"}},"ParentList":{"__deferred":{"uri":"http://sc-spstd-dev.mySite.com/it/pm/_api/Web/Lists(guid'7bd231eb-d4ac-435e-bf4d-faea7386ff2d')/Items(39)/ParentList"}},"FileSystemObjectType":0,"Id":39,"ContentTypeId":"0x0100C744EEAFCDCE644291DDD76900E3142D040100FE7A91994E36DE429609362ECC5ED4D2","Title":null,"Project_x0020_Name":"Silver Bullet","Objective":null,"Dept":{"__metadata":{"type":"SP.Taxonomy.TaxonomyFieldValue"},"Label":"45","TermGuid":"7551f9e3-5f42-4a40-86b9-9d5232238c44","WssId":45},"Team":{"__metadata":{"type":"SP.Taxonomy.TaxonomyFieldValue"},"Label":"46","TermGuid":"79659ae1-3b19-4104-b58b-8dc14833b88f","WssId":46},"PMId":40,"Tier":{"__metadata":{"type":"SP.Taxonomy.TaxonomyFieldValue"},"Label":"61","TermGuid":"0c76ec04-5136-460f-95b5-c82c0be5d7cf","WssId":61},"Global":true,"RGS":{"results":[{"__metadata":{"type":"SP.Taxonomy.TaxonomyFieldValue"},"Label":"R","TermGuid":"172aacb6-0452-40d7-abdb-e2cf6714bf28","WssId":59},{"__metadata":{"type":"SP.Taxonomy.TaxonomyFieldValue"},"Label":"S","TermGuid":"8655e913-def6-4219-90e4-19f60d99cca9","WssId":65}]},"Project_x0020_Status":{"__metadata":{"type":"SP.Taxonomy.TaxonomyFieldValue"},"Label":"60","TermGuid":"7b3bebae-b863-4a9c-aad2-660def87fc20","WssId":60},"Show_x0020_in_x0020_dashboard":true,"StartDate":"2013-01-01T08:00:00Z","Original_x0020_Go_x002d_Live_x00":"2014-02-04T08:00:00Z","Current_x0020_Go_x002d_Live_x002":"2014-04-04T07:00:00Z","Next_x0020_Gate":"2013-06-06T07:00:00Z","Issue":"
1
","Status_x0020_Overview":"Project used for PM training","Project":{"__metadata":{"type":"SP.FieldUrlValue"},"Description":"Silver Bullet","Url":"http://sc-spstd-dev.mySite.com/it/pm/SilverBullet"},"Current_x0020_Phase":{"__metadata":{"type":"SP.Taxonomy.TaxonomyFieldValue"},"Label":"51","TermGuid":"e251dc81-2329-4110-9611-095cf169dca2","WssId":51},"Prev_x0020_Status":{"__metadata":{"type":"SP.Taxonomy.TaxonomyFieldValue"},"Label":"57","TermGuid":"f65a7b18-9c71-4547-baba-1bf369abcb59","WssId":57},"ID":39,"Modified":"2013-12-11T19:12:20Z","Created":"2013-12-11T19:12:20Z","AuthorId":40,"EditorId":40,"OData__UIVersionString":"1.0","Attachments":false,"GUID":"b2e9a9ad-8c42-46a2-aad0-7001177692b5"}]}}
0
Comment
Question by:Techsavy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40431950
replace :
 alert("success: " + data.d.results.Project.Description);
by :
 alert("success: " + data.d.results[0].Project.Description);

test page : http://jsfiddle.net/sse0ujnc/
0
 

Author Closing Comment

by:Techsavy
ID: 40431961
thank you worked!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert Silverlight ERP To Angularjs,HTML5 3 59
JQuery conflicts/syntax issue 4 25
selected value 16 26
Table doesn't show the lines! 3 24
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question