This is my c# code:
public void addBoxScore(string[] playerstats)
{
Games gamestats = new Games();
gamestats.GAME_ID = Int32.Parse(playerstats[0]);
gamestats.TEAM_ID = Int32.Parse(playerstats[1]);
gamestats.TEAM_ABBREVIATION = playerstats[2];
gamestats.TEAM_CITY = playerstats[3];
gamestats.PLAYER_ID = Int32.Parse(playerstats[4]);
gamestats.PLAYER_NAME = playerstats[5];
gamestats.START_POSITION = playerstats[6];
gamestats.COMMENT = playerstats[7];
gamestats.MIN = Int32.Parse(playerstats[8]);
gamestats.FGM = Int32.Parse(playerstats[9]);
gamestats.FGA = Int32.Parse(playerstats[10]);
gamestats.FG_PCT = Int32.Parse(playerstats[11]);
gamestats.FGTHREEM = Int32.Parse(playerstats[12]);
gamestats.FGTHREEA = Int32.Parse(playerstats[13]);
gamestats.FGTHREE_PCT = Int32.Parse(playerstats[14]);
gamestats.FTM = Int32.Parse(playerstats[15]);
gamestats.FTA = Int32.Parse(playerstats[16]);
gamestats.FT_PCT = Int32.Parse(playerstats[17]);
gamestats.OREB = Int32.Parse(playerstats[18]);
gamestats.DREB = Int32.Parse(playerstats[19]);
gamestats.REB = Int32.Parse(playerstats[20]);
gamestats.AST = Int32.Parse(playerstats[21]);
gamestats.STL = Int32.Parse(playerstats[22]);
gamestats.BLK = Int32.Parse(playerstats[23]);
gamestats.TO = Int32.Parse(playerstats[24]);
gamestats.PF = Int32.Parse(playerstats[25]);
gamestats.PTS = Int32.Parse(playerstats[26]);
gamestats.PLUS_MINUS = Int32.Parse(playerstats[27]);
}
and this is my javascript that gets the data from the api and sends it to the controller.
var date = "05/05/2014";
$.ajax({
dataType: "jsonp",
type: "post",
crossDomain: true,
url: 'http://stats.nba.com/stats/scoreboard/?LeagueID=00&gameDate=' + date + '&DayOffset=0',
success: function (val) {
var result = val.resultSets[0].rowSet;
$.each(result, function (key, value) {
var gameID = this[2];
$.ajax({
dataType: "jsonp",
async: false,
type: "post",
crossDomain: true,
gameID: { gameID: gameID },
url: "http://stats.nba.com/stats/boxscore?GameID=" + gameID + "&RangeType=0&StartPeriod=0&EndPeriod=0&StartRange=0&EndRange=0",
success: function (gameinfo) {
var w = gameinfo.resultSets[0].rowSet[0];
if (w[4] == "Final") {
var pstats = gameinfo.resultSets[4].rowSet;
$.each(pstats, function (key, value) {
var playerstats = this;
$.ajax({
async: false,
type: "post",
url: "/Stats/addBoxScore",
data: { playerstats: JSON.stringify(playerstats) },
done: function (data) {
console.log(data);
},
error: function (jqXHR, err) {
console.log(err);
}
});
});
};
}
And this is what the data that the controller recieves looks like:
"[\"0041300201\",1610612764,\"WAS\",\"Washington\",2772,\"Trevor Ariza\",\"F\",\"\",\"37:20\",7,10,0.7,6,6,1,2,4,0.5,1,5,6,2,1,0,0,3,22,18]"
This is my model:
public class Games
{
[Key, Column(Order = 0)]
public int GAME_ID { get; set; }
public int TEAM_ID { get; set; }
public string TEAM_ABBREVIATION { get; set; }
public string TEAM_CITY { get; set; }
[Key, Column(Order = 1)]
public int PLAYER_ID { get; set; }
public string PLAYER_NAME { get; set; }
public string START_POSITION { get; set; }
public string COMMENT { get; set; }
public int MIN { get; set; }
public int FGM { get; set; }
public int FGA { get; set; }
public int FG_PCT { get; set; }
public int FGTHREEM { get; set; }
public int FGTHREEA { get; set; }
public int FGTHREE_PCT { get; set; }
public int FTM { get; set; }
public int FTA { get; set; }
public int FT_PCT { get; set; }
public int OREB { get; set; }
public int DREB { get; set; }
public int REB { get; set; }
public int AST { get; set; }
public int STL { get; set; }
public int BLK { get; set; }
public int TO { get; set; }
public int PF { get; set; }
public int PTS { get; set; }
public int PLUS_MINUS { get; set; }
public virtual Player player { get; set; }
}
Why does it put \ in every string in the array? And how do i parse it to my model?