![]() |
|
[.NET] Spliting up a string - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Spliting up a string (/showthread.php?tid=4755268) |
Spliting up a string - SIM-574702 - Mar 30, 2015 I have some experience in C programming but I'm trying to make an app that uses API to show some data. When request it sent to API it returns all the data in one single line like this Code {"mate":{"id":34467414,"name":"Mate","profileIconId":15,"summonerLevel":30,"revisionDate":1424799210000}}I've got requesting part covered from another tutorial but he just showed whole HTML source of youtube.com in one textbox. What I need is to split received data into 4 string variables, id,name,icon and level where each will contain only data between " ". * - Hiiro - Mar 30, 2015 Use JSON.net to parse the information. http://www.newtonsoft.com/json * - SIM-1676753 - Mar 30, 2015 You can use the DataContractJsonSerializer class. Example of it's use: https://gist.github.com/PatPositron/10076559 https://gist.github.com/PatPositron/cc2007bfcffb08708061 * - SIM-574702 - Mar 30, 2015 I'm not looking for something that complicated. I just want to split string on specific places by using basic commands. I'm doing this for myself because I need more examples of working with strings. This is what I made by following couple of tutorials. I know that I should've created functions instead of having everything under Button_Click but I'm just wondering if this is done properly with using basic commands. Code Imports System.Net* - Hiiro - Mar 30, 2015 (Mar 30, 2015 07:06 PM)matemisic Wrote: I'm not looking for something that complicated. I just want to split string on specific places by using basic commands. I'm doing this for myself because I need more examples of working with strings.Look into Regex if you don't want to handle the JSON with a Deserializer. * - Ninja - Mar 31, 2015 JSON parsing would be the best option, but you could always do this: Dim SplitString As String() = Variable.Split("characterhere") or Regex, which might be a better option. |