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

  • SEARCH
  • Home
  • 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 9190661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:30:50+00:00 2026-06-17T20:30:50+00:00

Does the Json.Encode() Helper use the JavaScriptSerializer class to encode a string to json?

  • 0

Does the Json.Encode() Helper use the JavaScriptSerializer class to encode a string to json?

I am getting a circular reference exception when using Json.Encode(Model) even though my class properties that are being serialized have the [ScriptIgnore] attribute.

My only guess is that maybe the Json.Encode() helper doesn’t use the JavaScriptSerializer to serialize to json but I can’t find the documentation anywhere on msdn.

@Html.Raw(Json.Encode(Model))

Here’s an example of one of the models that has a property that should not be serialized…

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Web.Script.Serialization;

namespace RobotDog.Entities {
    public class Character {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [MaxLength(200)]
        public string Name { get; set; }

        public virtual Person Person { get; set; }

        [ScriptIgnore]
        public virtual Movie Movie { get; set; }
    }
}
  • 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-17T20:30:51+00:00Added an answer on June 17, 2026 at 8:30 pm

    Does the Json.Encode() Helper use the JavaScriptSerializer class to encode a string to json?

    Yes.

    From the source code:

    private static readonly JavaScriptSerializer _serializer = Json.CreateSerializer();
    
    public static string Encode(object value)
    {
      DynamicJsonArray dynamicJsonArray = value as DynamicJsonArray;
      if (dynamicJsonArray != null)
        return Json._serializer.Serialize((object) (object[]) dynamicJsonArray);
      else
        return Json._serializer.Serialize(value);
    }
    

    where JavaScriptSerializer is System.Web.Script.Serialization.JavaScriptSerializer

    also to assist your issue see this thread

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

Sidebar

Related Questions

How does one turn any random object into a JSON string using Monodroid's System.Json
I am using CL-JSON to encode an object. It spits the encoded string in
Does anyone knows a java library that could easily encode java Maps into json
I'm trying to use the PHP json_encode function to encode some JSON to send
I am trying to call a Json.Encode(...) method in MVC 4 and I'm getting
I am trying to json encode an array,it does encode but i get lots
This code works 100% but when I try to use JSON it does not
I'm creating a JSON feed with PHP using echo json_encode($my_array) . The resulting string
Does anyone know there have any other way that (by not using json_encode and
Is there any reasons why PHP's json_encode function does not escape all JSON control

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.