Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JSON question

Posted on 2014-11-09
2
Medium Priority
?
160 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 2000 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

722 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