I have small problem with prepare table.
Generally I usually prepare this table in PHP:
array(2) {
["function"]=>
string(14) "saveStats"
["data"]=>
array(10) {
["id"]=>
string(28) "6079f20ac3_1344412683016_427"
["stat"]=>
array(2) {
[461]=>
string(572) "1834!:!606113;2636701;2532259;8615557991;"
[462]=>
string(664) "947679;1976657;1457921;1302869;2966923;2361071;6876943;5641369;560761;3469061;5438071;9646643;8575873;339307;9652169;2581441;5158451;6210209;6062971;2815237;3396139;2527643;2502571;7882529;536729;1171073;8825407;351427;1845373;8828471;1099463;6653011;5433293;86027;8258377;6748487;5237059;8006827;3996193;117389;7449523;9847147;3476761;7073981;7491493;1603837;8972801;699401;3354649;8120317;3405823;8545499;2672701;1373363;2397077;3417523;8772983;157999;6294929;6024589;6760669;5923937;4560691;8324143;824477;3575549;1372559;986287;4860203;5774323;1832353;4198973;3639841;9179101;718337;4949353;5745787;1608041;8169241;46549;3272723;7622267;"
}
["userAgent"]=>
string(67) "Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1"
["ip"]=>
string(3) "::1"
["referer"]=>
string(4) "Brak"
["limit"]=>
int(1)
}
}
Data in [“stat”] can be array 10 or 2 end each of them have “random” number (look at [461][462] etc)
This data I must later put to JSON (I use newtonsoft.Json).
How I can prepare this object in C# ?
Try this (.NET 4) (see below), the only issue are the columns 461 and 462, C# does not allow variable names starting with a number (I’ve renamed them to n461 and n462) but it’s easy to compensate for this using newtonsoft.Json see similar question here
I’ve used dynamic and anonymous classes but you could declare “real” classes of course depending on your needs. (if you are using .NET 3.5 or earlier this is a must)