C# / Json.net / 如何反序列化消息?
请帮助我下一步需要做什么?我需要将此消息放在他们的专用字符串中 但我不知道该怎么做
,使用字典怎么样?
我收到的消息是这样的..它位于一个名为 sServerResponse 的字符串中,
{"pcname": "Kat", "pause": [], "ip": "192.168.1.100", "paused": 0, "services": [], "session": "", "shop": [], "end": 0, "used": 0, "start": 0, "timeup": 0, "follow": "sui", "consq": {"1": "basic", "3": "rounding", "2": "minimum"}, "stas": 0, "price": 0, "pc_status": 1, "account_details": {"3": "Member", "2": "Staff/Member", "4": "Timecode"}, "msg": "Connection/Update accepted.", "mac": "00112233445", "others": [], "remarks": "", "ticker": {"units": 1}, "fixed_time": [], "account": "", "pause_tmp": {"s": 0, "e": 0}, "ver": {}, "status_details": {"1": "Idle", "0": "Offline", "5": "Fixed", "4": "Open", "7": "Mem", "6": "Extended", "8": "Timecode"}, "cmd": "nothing", "load": 0, "deposit": [], "data": {"fixed": [], "open": 0}, "restirctions": {"start_button": 0, "keys": [{"ctrl-esc": 0}, {"alt-tab": 0}], "mouse": 1, "drives": [{"c": 0}, {"d": 0}], "desktop": 0, "task_manager": 0, "keyboard": 1, "taskbar": 0, "control_panel": 0}}
请指导我..我做过无数的谷歌和我读过的主题。 json.net 上的示例甚至无法工作
编辑/更新:
我现在正在尝试这个
List<WrapperReader> datas;
datas = new JavaScriptSerializer(new SimpleTypeResolver()).Deserialize<List<WrapperReader>>(jsonInput);
}
但是数据是空的,这里可能是什么问题?
更新2
我有点明白是什么导致了
它的类出错。
如果我要接收一个字符串数组。然后在我的班级中我必须将其声明为数组 关于日期的小数和日期也是如此
。如果我要收到一个日期。我如何声明它才能包含日期?
我要完成编码,看看它是否真的是罪魁祸首
please help me on what i need to do next? i need this message to be inside their dedicated strings
but i got no idea how to do it
also how about using a dictionary?
the message that i receive is this.. its inside a string called sServerResponse
{"pcname": "Kat", "pause": [], "ip": "192.168.1.100", "paused": 0, "services": [], "session": "", "shop": [], "end": 0, "used": 0, "start": 0, "timeup": 0, "follow": "sui", "consq": {"1": "basic", "3": "rounding", "2": "minimum"}, "stas": 0, "price": 0, "pc_status": 1, "account_details": {"3": "Member", "2": "Staff/Member", "4": "Timecode"}, "msg": "Connection/Update accepted.", "mac": "00112233445", "others": [], "remarks": "", "ticker": {"units": 1}, "fixed_time": [], "account": "", "pause_tmp": {"s": 0, "e": 0}, "ver": {}, "status_details": {"1": "Idle", "0": "Offline", "5": "Fixed", "4": "Open", "7": "Mem", "6": "Extended", "8": "Timecode"}, "cmd": "nothing", "load": 0, "deposit": [], "data": {"fixed": [], "open": 0}, "restirctions": {"start_button": 0, "keys": [{"ctrl-esc": 0}, {"alt-tab": 0}], "mouse": 1, "drives": [{"c": 0}, {"d": 0}], "desktop": 0, "task_manager": 0, "keyboard": 1, "taskbar": 0, "control_panel": 0}}
please guide me.. countless googles ive made and topics i have read.
the sample on json.net didnt even work
EDIT/UPDATE:
i'm now trying this one
List<WrapperReader> datas;
datas = new JavaScriptSerializer(new SimpleTypeResolver()).Deserialize<List<WrapperReader>>(jsonInput);
}
but datas is empty, what may be the problem here?
UPDATE 2
i kind of figure whats making it to error
its the class.
if im going to receive a array of strings . then inside my class i must declare it as array to
same goes to decimals and dates
about dates.. if im going to receive a date. how do i declare it so it can contain a date?
im going to finish the coding see if its really the culprit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你好
我为你写了一个基本的例子。
您可以在没有 Json.NET 库的情况下使用。
}
Hi
I wrote a basic example for you.
You can use without Json.NET library.
}