?
Solved

how do i serialize this json in c#?

Posted on 2015-01-14
3
Medium Priority
?
114 Views
Last Modified: 2015-01-15
hello sir,i dont know how to serialize the following json

{"HashParams":{"YYBH":"113001","FN":"SP3_3002","JBR":"001","SESSIONID":"113001:2a660fe1-ac25-4d44-8ab0-a7d38e6d254a"},
"DataPackage":
{"ZYCFXMDR":
[{"YYXMBM":"011131","CFXMWYH":"222"},
  ]
}

im confusing the "ZYCFXMDR",if without the "ZYCFXMDR",i could use such CLASS & use the json.net to serialize it

public class HashParams
{
  pulbic string YYBH {get;set;}

  pulbic string FN {get;set;}

  pulbic string JBR {get;set;}

pulbic string SESSIONID {get;set;}

public iList<DataPackage> {get;set;}
 
}

public class DataPackage
{
  public string  YYXMBM  {get;set;}

public string  CFXMWYH {get;set;}
}
then i serialize it in JSON.NET

if without the "ZYCFXMDR",i could do something like the following
string output = JsonConvert.SerializeObject(HashParams),however i dont know what to do if "ZYCFXMDR" exists

best regrads
ken
0
Comment
Question by:ken yup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1500 total points
ID: 40549849
Have you looked at http://json2csharp.com/ yet? It seems pretty good at transforming JSON structure into C# class structure (see attached).
Untitled.png
0
 

Author Comment

by:ken yup
ID: 40551154
thanks,i apperciate it,however the tools is not good enough,becuase it cant parse my json
 Parsing your JSON didn't work. Please make sure it's valid.
Already did that? Please let me know so I can fix it.
but with your tips,i have found this tools,it's useful
https://jsonclassgenerator.codeplex.com/
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40551251
Your JSON appeared to be missing a closing curly brace. When I added that in, the JSON parsed fine.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question