Json does not exist in the namespace System

前端 未结 5 886
野趣味
野趣味 2020-12-06 00:19

In this tutorial: http://www.asp.net/web-api/videos/getting-started/custom-validation Jon uses

dynamic error = new JsonObject();

with

相关标签:
5条回答
  • 2020-12-06 00:48

    Using System.json will not work for .Net 4 framework. The library is deprecated. To check it try:

    1. Go Add reference... to project.
    2. On .Net Tab, Search System.json, you will not find any.

    That means, it is deprecated.

    0 讨论(0)
  • 2020-12-06 01:00

    The Json object works only from Controller class and not outside. Even if we refer System.Web.MVC outside controller, we have access only to JsonResult and not to Json as Json object is protected object of JsonResult. Please refer the below documentation which explains that,

    http://msdn.microsoft.com/en-us/library/dd504936(v=vs.118).aspx

    0 讨论(0)
  • 2020-12-06 01:01

    http://www.webcosmoforums.com/asp/32551-type-namespace-name-json-does-not-exist-namespace-system-runtime-serialization.html

    Most likely you are missing a reference to System.ServiceModel.Web

    Make sure your application is targeting the .Net 4.5 framework in the project properties.

    The System.Json objects are only available in 4.5

    Edit:

    Use Nuget to install system.json : 'Install-Package System.Json'

    How to parse JSON without JSON.NET library?

    0 讨论(0)
  • 2020-12-06 01:04

    Try this:

    PM> Install-Package System.Json -Version 4.0.20126.16343
    

    Per: http://nuget.org/packages/System.Json

    It worked!

    If you have questions on how to add enter nuget code, please follow the link below: http://docs.nuget.org/docs/start-here/using-the-package-manager-console

    0 讨论(0)
  • 2020-12-06 01:07

    If you want to use other .Net json serializer, you can use the following:

    1. go to manage nuget package.
    2. search json.net.
    3. click install.

    for more details, follow - http://netfx.codeplex.com/

    0 讨论(0)
提交回复
热议问题