jsonSerialization Element (ASP.NET Settings Schema)

Configures JSON serialization.

configuration Element (General Settings Schema)
  system.web.extensions Element (ASP.NET Settings Schema)
    scripting Element (ASP.NET Settings Schema)
      webServices Element for scripting (ASP.NET Settings Schema)
        jsonSerialization Element (ASP.NET Settings Schema)

<jsonSerialization 
      maxJsonLength="number" 
      recursionLimit="number">
    <converters>... </converters>
</jsonSerialization>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

maxJsonLength

Optional attribute.

Configures the maximum length of the JSON string (the maximum number of UTF-8 characters).

The default length is 102400.

recursionLimit

Optional attribute.

Specifies the maximum depth to which to serialize types. The default recursion limit is 100.

Child Elements

Element

Description

converters

Specifies custom converters for JSON serialization.

Parent Elements

Element

Description

configuration

Specifies the root element in every configuration file that is used by the common language runtime and .NET Framework applications.

system.web.extensions

Specifies the root element for the ASP.NET extensions configuration section, and contains elements that configure ASP.NET services and control their behavior.

scripting

Specifies configuration settings for ASP.NET AJAX-enabled Web pages and for enabling or disabling application services.

webServices

Configures Web services and controls their behavior.

Remarks

The jsonSerialization element enables you to specify custom converters and override default settings for maximum length and recursion limit.

Note

This configuration element does not turn JSON serialization on and off. Also, it applies to custom services and application services whose clients use the JSON protocol for data exchange.

For more information, see How to: Configure ASP.NET Services in ASP.NET AJAX.

Example

The following example shows how to configure JSON serialization.

<jsonSerialization maxJsonLength="50" recursionLimit="10" /> 

Element Information

Configuration Section Handler

System.Web.Configuration.ScriptingJsonSerializationSection

Configurable Locations

Machine.config

Root-level Web.config

Application-level Web.config

Virtual or physical directory–level Web.config

Validation File

Microsoft Internet Information Services (IIS) 5.0, 5.1, 6.0, or 7.0

The .NET Framework version 3.0

See Also

Tasks

How to: Configure ASP.NET Services in ASP.NET AJAX

Concepts

ASP.NET Configuration Overview

ASP.NET Configuration File Hierarchy and Inheritance

Reference

System.Web.Configuration

Other Resources

ASP.NET Configuration Settings

ASP.NET Configuration API