php - How do i convert a JSON string to a native C# array using a namespace compatible with Windows Store Apps? -


i trying make windows 8 store app gets results mysql database php page rest service.

i'm looking php return json representation of array of strings , have done happily when dong same between javascript , php. need take same json string , use in c# windows 8 store app, there way take return of php page , convert normal c# array, not dictionary or more complex collection.

the database have 4 fields if have use special object made will, i'd rather didn't function doesn't require amount of data.

the php page - $search_text passed in via get:

$databaseconnection = new mysqli(db_host, db_user, db_password, db_name);     if ($databaseconnection->connect_error)     {         echo "database connection failed: $databaseconnection->connect_error";     }     else     {         $search_text = $search_text."%";         $query = "select distinct street gritroutes street ? limit 5";         $statement = $databaseconnection->prepare($query);         $statement->bind_param('s', $search_text);         $statement->execute();         $statement->store_result();         $statement->bind_result($street);         $autonumber = 1;          while ($statement->fetch())          {                        $resultarr[] = $street;          }          $statement->close();          echo json_encode($resultarr);     } 

just clear. writing windows store app, system.web namespace unavailable can't use javascriptserializer.

just add matthew's answer, can deserialize using json.net (you can nuget), you'd like:

list<string> mystrings = jsonconvert.deserializeobject<list<string>>(myjson); 

this in:

using newtonsoft.json; 

check out this article practical example.

edit - i'd throw in link, since it's awesome.

i hope helps.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -