How to convert an HTML table to JSON and use the JSON with JSON.NET?


HOME ยป Web Design

I'm asking this question because I think it's one that we run into
from time to time. I needed to take an HTML table that had been
manipulated client side and send the resulting table data to the
server for processing. Additionally, I wanted to map this using
JSON.NET directly to my business object(s).

I am trying to find a way to serialize an object to json using
json.net. The object i am trying to serialize has a XElement property,
and i would like to keep it as is so.


is there a way to do
that in json.net ? or what the mechanism to transfer xml data in json
object?

Programming Languages

I'm asking this question because I think it's one that we run into
from time to time. I needed to take an HTML table that had been
manipulated client side and send the resulting table data to the
server for processing. Additionally, I wanted to map this using
JSON.NET directly to my business object(s).

Web Design

I am converting my datatable to c# generic list.



DataTable dt = mydata();
List<DataRow> list =
dt.AsEnumerable().ToList();

Now how can i convert
this list to json using json.net? Any suggestion.

/>

Sample of json format should be like this,

/>{"Table" : [{"userid" : "1","name" :
"xavyTechnologies","designation" : "",
"phone" :
"9999999999","email" : "test@test.com","role" : "Admin","empId" :
"",
"reportingto" : ""},{"userid" : "2","name" :
"chendurpandian","designation" :
"softwaredeveloper","phone" :
"9566643707","email" : "chendur.pandia@gmail.com",
C & C++ & C#

I have the following response:


{
"data":
[
{
"name": "This is a test 123",

"start_time": "2013-12-02T18:00:00+0530",
"end_time":
"2013-12-02T20:00:00+0530",
"location": "Mount
Lavinia",
"id": "525447507473743",

"rsvp_status": "attending"
},
{

"name": "This is a test event",
"start_time":
"2013-12-02T18:00:00+0530",
"end_time":
"2013-12-02T20:00:00+0530",
"location": "Mount
Lavinia",
"id": "560383743988530",

"rsvp_status": "attending"
Programming Languages

I'm trying to consume SmartyStreets JSON LiveAddress API and I'm
having some difficulties. I will admit that I'm not too familiar with
JSON. Anyways, I've tried a few different methods and I usually end up
with the error "Cannot deserialize JSON array into type Metadata".


Here is the JSON string:

/>[{"input_index":0,"candidate_index":0,"delivery_line_1":"1600
Amphitheatre Pkwy","last_line":"Mountain View CA
94043-1351","delivery_point_barcode":"940431351000","components":{"primary_number":"1600","street_name":"Amphitheatre","street_suffix":"Pkwy","city_name":"Mountain
View","state_abbreviation":"CA","zipcode":"94043","plus4_code":"1351","delivery_
Programming Languages

I am been stuck on this for 3 days now...I have been accessing the
twitter api to pull a user_timeline for a list of users and the json
that comes back is impossible to work with. I tried to deserialize it
using javascriptserializer and get an error:


invalid
object passed in , ':' or '}'


Now this is frustrating
since I expect the json being returned to be error free. Then I tried
json.net and split the posts using string.split and tried to convert
each post to Jobject or jarray. for Jarray I get

/>

'unexpected end of content while loading jArray


for
jobject:


'error reading JObject from jsonrea

Javascript

- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow