JSON °øºÎÇÒ·Á°í miniJSON ³Ö°í ÀÌ·¡Àú·¡ Çغ¸°í Àִµ¥ ¸·Çô¼..¤Ð¤Ð
JSON ÆÄÀÏÀº
[
{
"emptyChk" : true,
"name" : "aaa",
"ID" : 1,
"mrt" : 15
},
{
"emptyChk" : true,
"name" : "bbb",
"ID" : 2,
"mrt" : 22
}
]
ÀÌ·¸°Ô µÇ¾îÀÖ°í,
C# ½ºÅ©¸³Æ®´Â
TextAsset userAsset = Resources.Load("userAsset") as TextAsset;
IList userList = (IList)Json.Deserialize(userAsset.text);
foreach (IDictionary uPerson in userList)
{
bool emptyChkTemp = (bool)uPerson["emptyChk"];
string nameTemp = (string)uPerson["name"];
int IDTemp = (int)uPerson["ID"];
int mrtTemp = (int)uPerson["mrt"];
}
ÀÌ·±½ÄÀε¥,
int IDTemp = (int)uPerson["ID"]; ÀÌ ÁÙ¿¡¼
InvalidCastException: Cannot cast from source type to destination type.
¶ó°í ij½ºÆ® ¿À·ù°¡ ¶ß³×¿ä.. ¾îµð°¡ À߸øµÈ °É±î¿ä?
boolÀ̶û stringÀº Àß µÇ´Âµ¥ int¶û float µé¾î°¡¸é ij½ºÆà ¿À·ù ¤Ð
Àâ´ã | 3158¸íÀÌ Àоú¾î¿ä. 13.59.103.62