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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:31:33+00:00 2026-05-22T01:31:33+00:00

I am writing a json using Newtonsoft.json.JsonTextWriter. Here is my code: StringBuilder sb =

  • 0

I am writing a json using Newtonsoft.json.JsonTextWriter.
Here is my code:

StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
JsonWriter jsonWriter = new JsonTextWriter(sw);

jsonWriter.Formatting = Formatting.Indented;

jsonWriter.WritePropertyName("Name");
jsonWriter.WriteValue("Allan");

And i am assuming that sw has the json format {“Name”: “Allan”}. How can i get the written text in some string variable so that i can use this json data in my http request?

  • 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-22T01:31:34+00:00Added an answer on May 22, 2026 at 1:31 am

    My answer is now not relevant, since the code sample in the question has been edited to include these lines, left here for posterity, see comments for more info.


    You will need to add the following to close the JSON elements properly:

    jsonWriter.WriteEndObject();
    

    Then call the StringBuilder’s ToString() method:

    string strMyString = sb.ToString(); //JSONString
    

    References:

    StringWriter Constructor (MSDN) | Reading and Writing JSON (NewtonKing.com)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an Applet that makes some JSON-RPC calls. I'm using the Google JSON
Does anyone have experience writing a Facebook application using GWT with GAE? I'm new
I am writing a simple proof-of-concept web service using ASP.NET MVC3 controller with JSON
I'm writing an iPhone native app using the JSON framework. My app is accessing
Hi searched through the questions here, but couldn't find anything. I'm new at writing
I am using json developing android sdk. I found writing json string is annoying,
I'm writing a application where the user can write json-code and store that json
I am writing a JSON response from a perl/cgi program. The header's content type
I'm writing an RSS to JSON parser and as a part of that, I
I'm writing some acceptance tests for a java webapp that returns JSON objects. I

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.