(100分)json存放到数据库问题。在线等 急急急!!!(大家给力啊)
最近做一个网站需要从另外一个网站的api获取json数据然后存放到自己的数据库。可是本人对于json操作一窍不通,所以请教各位大神。 废话不多说了 代码如下
json文件内容 我已经清理一大部分相同结构的数据:
(里面主要就是imei的Service 列表 我把它放到数据库2张表里面groups跟Services )
{
"SUCCESS": [
{
"MESSAGE": "IMEI Service List",
"LIST": {
"MOVISTAR SPAIN": {
"GROUPNAME": "MOVISTAR SPAIN",
"SERVICES": {
"3": {
"SERVICEID": 32,
"SERVICENAME": "MOVISTAR NOKIA INSTANTE",
"CREDIT": 4,
"TIME": "1-30 Minutes",
"INFO": "<p style="text-align: center;"><span style="color: #ff0000;" data-mce-mark="1">SERVICIO INSTANTE DE 0-10 MINS PARA NOKIAS MOVISTAR???No dct3/4???</span></p>\r\n<p style="text-align: center;"><span style="color: #ff0000;" data-mce-mark="1">CON GUIDADO SERIA C ???mayoria son20 digitos</span></p>\r\n<p style="text-align: center;">?????é?¨?????o ?????ˉ20???:?<span style="font-size: medium;"> <strong>C?3????(c2 c5)???<strong>Nokia 7230</strong></strong></span></p>\r\n<p style="text-align: center;"><span style="color: #ff0000;" data-mce-mark="1"><strong>SERIA ASHA 100, 101, 311, 500 y todos los de estas series</strong></span></p>\r\n<p style="text-align: center;"><span style="color: #ff0000;" data-mce-mark="1"><strong> Y WINDOWS PHONE Lumia</strong></span></p>",
"Requires.Network": "None",
"Requires.Mobile": "None",
"Requires.Provider": "None",
"Requires.PIN": "None",
"Requires.KBH": "None",
"Requires.MEP": "None",
"Requires.PRD": "None",
"Requires.Type": "None",
"Requires.Locks": "None",
"Requires.Reference": "None"
},
"8": {
"SERVICEID": 77,
"SERVICENAME": "MOVISTAR NOKIA 20 NCK",
"CREDIT": 12,
"TIME": "1-30 Minutes",
"INFO": "<p style="text-align: center;"><span style="font-size: small; color: #ff0000;"><strong>ALL NOKIA MOVISTAR SPAIN 20 DIGITS ,</strong></span><strong style="color: #ff0000; font-size: small;">NOT SUPPORTED LUMIA 820 </strong></p>\r\n<p style="text-align: center;"><strong style="color: #ff0000; font-size: small;">Para Confirma si es 20 nck o no ,check info de movil con programa infinity ,descarga desde pagina aportado</strong></p>\r\n<p style="text-align: center;"> </p>",
"Requires.Network": "None",
"Requires.Mobile": "None",
"Requires.Provider": "None",
"Requires.PIN": "None",
"Requires.KBH": "None",
"Requires.MEP": "None",
"Requires.PRD": "None",
"Requires.Type": "None",
"Requires.Locks": "None",
"Requires.Reference": "None"
}
}
},
"VODAFONE SPAIN": {
"GROUPNAME": "VODAFONE SPAIN",
"SERVICES": {
"5": {
"SERVICEID": 50,
"SERVICENAME": "VODAFONE NOKIA BB5 SL3",
"CREDIT": 5,
"TIME": "1-60 Minutes",
"INFO": "<p style="text-align: center;"><strong><span style="font-size: medium; color: #ff0000;">Nokia lumia, nokia 100, 610 y nokias 20 digitos no soportados!</span></strong></p>\r\n<p style="text-align: center;"><span style="color: #ff0000; font-size: small;"><strong>Nokia vodafone instante en horario de la tienda</strong></span></p>\r\n<p style="text-align: center;"><span style="color: #ff0000; font-size: small;"><strong>20???? ?????????o???LUMIA?????ˉ???</strong></span></p>\r\n<p style="text-align: center;"><span style="color: #ff0000; font-size: small;"><strong> </strong></span></p>",
"Requires.Network": "None",
"Requires.Mobile": "None",
"Requires.Provider": "None",
"Requires.PIN": "None",
"Requires.KBH": "None",
"Requires.MEP": "None",
"Requires.PRD": "None",
"Requires.Type": "None",
"Requires.Locks": "None",
"Requires.Reference": "None"
},
"10": {
"SERVICEID": 95,
"SERVICENAME": "VODAFONE SONY&SONY ERIC(RAPIDO)",
"CREDIT": 16,
"TIME": "1-24 Hours",
"INFO": "<p style="text-align: center;"><span style="color: #ff0000; font-size: medium;">VODAFONE PHONE ,NO NOKIA Y WINDOWN PHONE,NO IPHONE? </span></p>\r\n<p style="text-align: center;"><span style="color: #ff0000; font-size: medium;">SAMSUNG CODIGO NO LLEVA DEFREEZE</span></p>",
"Requires.Network": "None",
"Requires.Mobile": "None",
"Requires.Provider": "None",
"Requires.PIN": "None",
"Requires.KBH": "None",
"Requires.MEP": "None",
"Requires.PRD": "None",
"Requires.Type": "None",
"Requires.Locks": "None",
"Requires.Reference": "None"
}
}
}
}
}
],
"apiversion": "2.0.0"
}
"SERVICES":?{
"3":?{
class x1
{
public x2[] SUCCESS;
}
class x2
{
public string MESSAGE;
public x3[] SPAINS;
private object LIST
{
set
{
SPAINS = value != null ? ((fastCSharp.setup.cSharp.ajax.jsonNode)value).Dictionary.Values.getArray(node => fastCSharp.setup.cSharp.ajax.parseJson.Get<x3>(node)) : null;
}
}
}
class x3
{
public string GROUPNAME;
public x4[] SERVICES_;
private object SERVICES
{
set
{
SERVICES_ = value != null ? ((fastCSharp.setup.cSharp.ajax.jsonNode)value).Dictionary.Values.getArray(node => GetSERVICES(node)) : null;
}
}
private static x4 GetSERVICES(fastCSharp.setup.cSharp.ajax.jsonNode node)
{
System.Collections.Generic.Dictionary<string, fastCSharp.setup.cSharp.ajax.jsonNode> dictionary = node.Dictionary;
string Requires = "Requires.";
foreach (string key in dictionary.Keys.getArray())
{
if (key.StartsWith(Requires)) dictionary[key.Substring(Requires.Length)] = dictionary[key];
}
return fastCSharp.setup.cSharp.ajax.parseJson.Get<x4>(node);
}
}
class x4
{
public int SERVICEID;
public string SERVICENAME;
int groupid;
public decimal CREDIT;
public string TIME;
public string INFO;
public string Network;
public string Mobile;
public string Provider;
public string PIN;
public string KBH;
public string MEP;
public string PRD;
public string Type;
public string Locks;
public string Reference;
}