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 3696118
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:42:00+00:00 2026-05-19T04:42:00+00:00

I am testing out json.net . I would like to use its linq-to-json syntax

  • 0

I am testing out json.net. I would like to use its linq-to-json syntax to return json from a function attributed [WebMethod] but I am getting errors.

For example if I use in the code behind

[WebMethod, ScriptMethod(UseHttpGet = true)]
public static JObject GetStuff() {
    return new JProperty("string", "value");
}

Being called by the following javascript:

  PageMethods.GetStuff(/* parameters */, function(data) {
      // do stuff with data
  });

I get the error “Cannot access child value on Newtonsoft.Json.Linq.JValue”.

What should I be returning to ensure that my javascript data object gets filled with JSON?

  • 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-05-19T04:42:01+00:00Added an answer on May 19, 2026 at 4:42 am

    Why not simply returning objects and leaving the JSON serialization to the underlying infrastructure:

    public class MyModel
    {
        public string Value { get; set; }
    }
    

    and in your web method:

    [WebMethod, ScriptMethod(UseHttpGet = true)]
    public static MyModel GetStuff() {
        return new MyModel {
            Value = "some value"
        };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am starting out with automated testing and I would like to test one
I personally don't use FxCop yet. We want to work out the unit testing
I use FireFox as my main browser, especially when testing out my site, Avoru
I've been testing out the performance and memory profiler AQTime to see if it's
I'm testing out my application with the hopes of migrating to SQL Server 2008
I'm finally starting out with unit testing, having known that I should be doing
I am starting out with unit testing, I have a method that uses the
I'm having trouble figuring out how to get the testing framework set up and
I am just starting out with DI & unit testing and have hit a
Testing: return request.getCookies() == null; is not an appropriate way test. Is there another

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.