Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a json file called "~/data.txt" resulting from a "Serializer" in Default.aspx.cs which is placed into the Hidden1 textbox.

Trying to recreate it in json.aspx page.

Default.aspx
ASP.NET
<form action="json.aspx" method="post">
    <input id="Hidden1" type="hidden" runat="server" />
</form>

json.aspx
JavaScript
<script type="text/javascript">
    $.ajax(
         {
             url: "~/Default.aspx",
             contentType: 'application/json',
             data: JSON.stringify("Hidden1.Value"),
             dataType: "json",
             type: "POST"
         }).done(function (result) { });

</script>
Posted
Updated 1-Oct-14 7:55am
v5
Comments
Sergey Alexandrovich Kryukov 1-Oct-14 13:47pm    
Do you want to serialize it in C#?
What have you tried so far?
—SA
Teledextri 1-Oct-14 13:56pm    
I have already serialized in Default.aspx.cs.

I want to deserialize in json.aspx from the post method from Hidden1(where the serialized Data resides).
Sergey Alexandrovich Kryukov 1-Oct-14 14:12pm    
Okay. Let's see... Indicate where it was serialized and where it should be deserialized.
.NET to .NET
Javascript to .NET.
Anything else?
What's the problem?
—SA
Teledextri 1-Oct-14 14:23pm    
.net to .net
Sergey Alexandrovich Kryukov 1-Oct-14 14:31pm    
Thank you. Use DataContractJSONSerializer. I answered, please see.
—SA

1 solution

Suppose you serialize in Javascript, need to deserialize in .NET. Please see my past answers:
How To Convert object type to C# class object type[^],
how to conver multi level json data to C# Object?[^].

If you do both in .NET, the solution is just using DataContractJSONSerializer. Please see my past answer:
deseralize a json string array[^].

See also: Using Data Contracts[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900