Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9187957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:53:58+00:00 2026-06-17T19:53:58+00:00

This is my first stack overflow post so cut me some slack :). I

  • 0

This is my first stack overflow post so cut me some slack :).

I have been struggling quite a while now with this issue.

Currently my WCF reads data from a database and returns it as JSON.

This is how it looks:

{
    "shoppinglistitemsResult": [
        {
            "description": "this is my notes description",
            "name": "mynotename",
            "pid": "1",
            "status": "1",
            "username": "test"
        }
    ]
}

I want it to look like this:

{
    "shoppinglistitemsResult": [
        {
            "description": "123",
            "name": "123",
            "pid": "123",
            "status": "123",
            "username": "test"
        }
    ],
    "success": 1
}

With the extra object at the end.

[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "displayAllNotes?name={username}&pass={password}")]
List<Service1.wsNotes> shoppinglistitems(string username, string password);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:53:59+00:00Added an answer on June 17, 2026 at 7:53 pm

    You would need to return an object that contains both the list and the success property instead of the list directly. Think of every set of curly braces in JSON as a new object/class that needs to be created and everything that is comma separated as properties on that object. So your outer curly braces would need to be represented by a class with two properties (shoppinglistitemsResult and success). You would need a second class for all of the items in your list.

    Here’s a way you can do this with generics. I’ve also taken the liberty to include a couple of additional properties you might want to use. I’ve also included a Response type with no “Result” for operations that do not need to return values, but might want to return a success or error message.

    [DataContract]
    public class Response : IExtensibleDataObject
    {
        public Response()
        {
            Success = true;
            ErrorMessage = null;
        }
    
        [DataMember]
        public bool Success { get; set; }
        [DataMember]
        public string ErrorMessage { get; set; }
    
        public ExtensionDataObject ExtensionData { get; set; }
    }
    
    [DataContract]
    public class Response<TResult> : Response
    {
        [DataMember]
        public TResult Result { get; set; }
    }
    

    And then your operation contract would look something like this…

    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "displayAllNotes?name={username}&pass={password}")]
    Response<List<Notes>> GetShoppingListItems();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ALL, This is my first post on Stack Overflow. I have been programming in
Ok this is my first post on Stack Overflow I have been reading for
I have been using Stack Overflow for a number of months now, but this
This is my first Stack Overflow post! The community has been a great help!
I have been reading this blog post and this stack overflow post but I
This is my first post to stack overflow. I've been lurking this site for
This is my first post on stack overflow, so I apologize if I have
This is my first question here. I have been searching Stack Overflow and other
this is my first ever post to Stack Overflow and it's because I've been
This is my first post on Stack Overflow. I have searched google for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.