Split a string into values
-
Hi, I receive a string from an API like this example: {"id":"30535","email":"myemail@yahoo.com","first_name":"John","last_name":"Smith","gender":"male","friends":{"data":[{"name":"Helen Ford","id":"68304"},{"name":"Leo Pitt","id":"4732"}] I'd like to split and save the values into these string personId string email string firstName string lastName string gender and for friends values into an array that contains these values "personId" and "name" (for each set of records) I'd really appreciate it if someone could help me.
-
Hi, I receive a string from an API like this example: {"id":"30535","email":"myemail@yahoo.com","first_name":"John","last_name":"Smith","gender":"male","friends":{"data":[{"name":"Helen Ford","id":"68304"},{"name":"Leo Pitt","id":"4732"}] I'd like to split and save the values into these string personId string email string firstName string lastName string gender and for friends values into an array that contains these values "personId" and "name" (for each set of records) I'd really appreciate it if someone could help me.
It looks like serialized JSON. You can deserialize it into and object and access the values easily (and also, you can assign those values into string variables if you want). There is a lot of material available on the internet regarding JSON handling in C# Check some links below to help you out with JSON deserialization: JSON example[^] Deserialize JSON with C#[^] http://stackoverflow.com/questions/22580141/json-newtonsoft-deserialize-object-containing-a-list-of-string[^]
-
Hi, I receive a string from an API like this example: {"id":"30535","email":"myemail@yahoo.com","first_name":"John","last_name":"Smith","gender":"male","friends":{"data":[{"name":"Helen Ford","id":"68304"},{"name":"Leo Pitt","id":"4732"}] I'd like to split and save the values into these string personId string email string firstName string lastName string gender and for friends values into an array that contains these values "personId" and "name" (for each set of records) I'd really appreciate it if someone could help me.