.Net Regex To Parse Specific JSON Format

Feb 20, 2010

I'm writing a little web service which generates SO/SF/SU/MSO user flair in the form of an image with various "themes". I find this preferable to using the HTML/JS solutions offered by SO as it's more flexible and also works better in forum signatures.

I'm retrieving the data using the apparently unofficial API (More info here). I can have the data in HTML or JSON. I assumed the JSON would be easier to parse.

Unfortunately, I'm not great at regexes. and the best I can come up with is some very hacky sub-stringing. I believe a regex should be the most elegant solution

regex that matches ID, GravatarURL, ProfileURL, DisplayName, Reputation and Badge Counts (Bronze/Silver/Gold).

FWIW This is to be used in a VB.Net project (in case that affects the syntax at all)

[Code].....

In case any of you are interested, some screenshots of the flair as a work in progress are available here: Me, Jeff Atwood, Joel Spolsky

View 2 Replies


ADVERTISEMENT

Parse And Extract Specific Elements Out Of A JSON?

May 9, 2011

how to parse and extract specific elements out of a JSON that I obtain from a web source. Using Visual Studio 2010 and VB. I can get the JSON but I haven't been able to find any examples or tutorials regarding parsing the data, locating specific elements and their associated data.

View 1 Replies

Using JSON.NET To Parse JSON Generated Through PHP?

Mar 2, 2010

I'm sure this has been asked before but I'm not finding quite the information I'm needing so I thought I'd post this.

I've written a PHP script that returns a simple JSON object that looks like this:

{"status":"success","level":"admin"}

I'm doing a standard web request that submits the required data to the script over the internet and that's working fine.

Now, I want to use JSON.NET to pull out the individual variables so I can know what the values of "status" and "level" are. The problem is, I have no idea where to start.

I'm doing this in VB.NET (on the .NET Compact Framework).

View 1 Replies

C# - Parse JSON String Into DataSet?

Nov 16, 2011

I have to the replication.That time have to pass String as JSON

{"Table1" :
[
{"Name" : "MyCustomer","Description" : "cutomer","Status" : "1"}, {"Name" : "Kiraa","Description" : "My","Status" : "1",}[code]......

This is my format of JSON result. I want to convert to DataSet.I have installed JSON.NET library. I am using C#.net

public bool convertJSONToDataSet(string strBusinessUnit, string strExecutiveCode, string strTableName, String jsonContent)
{
DataSet dataset = JsonConvert.DeserializeObject<String>(jsonContent);[code].....

here this statement is wrong DataSet dataset = JsonConvert.DeserializeObject<String>(jsonContent); how to covert to a JSON string to a Dataset.

View 1 Replies

JSON Stringify And Parse Capability For VB

Aug 11, 2009

I looked on the JSON.org website but I couldn't find any JSON library for Visual Basic .NET, does one exist?

View 4 Replies

Parse Json From Such As Twitter Etc In Applications?

Mar 27, 2011

How can I parse json from such as twitter etc in vb.net applications.

View 2 Replies

.net - Parse Numbers From String Using Regex In .NET?

Feb 16, 2010

I am trying to parse the digits to store in a variable from a string in VB.NET (would like to also include the decimal point).

Here is an example string: Refund issued for $27.74

View 2 Replies

Regex To Parse HTML Tables

Dec 19, 2010

I am trying to remove the tables within an HTML file, specifically, for the following document, I'd like to remove anything within the tags <TABLE....> and </TABLE>. The document contains multiple tables with texts in between.

The expression that I came up with, <TABLE.*>s*[s|S]*</TABLE>s*, however would remove the text in between the tables. In fact it would remove everything between the first <TABLE> and the last </TABLE> tags. I would like to keep the texts in between and only remove the tables.

[Code]....

View 2 Replies

VS 2008 RegEx : How To Parse This File

Apr 7, 2009

I'm messing around with regular expressions and I can't seem to figure out how to parse this file.It's basically a lua file containing a table like:

TableName = {
["QuotedString"] = {
["QuotedString"] = {

[code]....

Some things with the file are standard, like the "TableName" (Never in quotes) starts the table. Variables always have [" "] around them and then equal something like ["Test"] = 0. However, the variable could have multiple variables within it. split up the file within each {} and then try to parse each ["QuotedString-Key"] = 0?

View 28 Replies

JSON.Net - DeserializeObject Format?

Nov 24, 2011

I'm using JSON.Net to try and deserialize some survey responses from SurveyGizmo.Here's a snapshot of the data I'm reading in:

{"result_ok":true,
"total_count":"44",
"page":1,

[code].....

View 1 Replies

RegEx - Parse CSV File And Replace Certain Characters

Sep 2, 2010

I've used regular expressions in the past. I have an app that parses a .csv file and replaces certain characters (commas). Here's an example..
item1, item2, item3, fruits are apples, oranges, grapes. Squash is a vegetable, not a fruit.
What my app does is search each line between character1 and character18 and replace all "," with "~". How this is done through regular expressions?

View 2 Replies

Javascript - .Net Json Serialization Format?

May 16, 2012

I was hoping someone may be able to point me in the right direction in regards to the format of a Json.I've never really worked with Json's and Serialization before so it's all a little new.I need to return a Json from .Net in the following format.[[Date.UTC(2011,12,14,8), 8], [Date.UTC(2011,12,14,9), 1]]

I'm almost there but am struggling with the format of my string, as by default the string is quoted. This is what I have:

[Code]...

View 2 Replies

Pass Json Data In A Particular Format

Oct 8, 2010

I have to pass my Json data in a particular format. My app is coded in vb. The following is my code :

[Code]...

View 1 Replies

Web Services - POST A JSON To A Specific Url Using .NET?

Sep 12, 2011

I'm a newbie about web services in VB.NET. I'm making a desktop application that will talk to JIRA[URL]..They provided a REST api that I decided to use. The first step is to login which they say that...

"To log in to JIRA, you need to POST a username and password in JSON format..."
{"username" : "admin", "password" : "admin"}
to this url...
https://addressgoeshere (we are using https)

Can someone provide me a sample code to do this so I can have a guide and a good start?

View 2 Replies

C# - Parse Using Regex Class Of System.Text.RegularExpressions

Mar 4, 2011

I have a string which i need to parse using Regex class of System.Text.RegularExpressions. I need to find if the first 2 characters of the string are either "00" or "07" or "16" or "23".

View 1 Replies

C# - Using .NET Regex To Parse WSUS Updates For Currently Installed Packages?

Apr 5, 2012

Problem: Current regex pattern does not filter all lines. Adding ^ to the beginning and $ to the ending of the pattern seems to break it as well. If I try it ont gives partial results using options(multiline & case insensitive). Using it in the application returns nothing at all.

View 1 Replies

RegEx To Parse Valid Paths From A Text File?

Sep 27, 2011

I'm attempting to parse a text file containing several Windows paths; I'd like to use regular expressions if possible, and I'm using VB.NET.The file is formatted somewhat like so:

M - Network Mode
C:ClientSystem - System Path
C:ClientProducts - Product Path

[code].....

View 2 Replies

Data To Json String And Send It To A Specific URL

May 3, 2011

this is the JSON string the data is required in to be sent using a given URL.[code]I am using VB.net and i need to create this string using VB.net. I tried using namevaluecollection and doing a POST. I also tried making a string and send data using GET. Both failed. how can i do this?

View 2 Replies

RegEx - How To Retrieve String Variable From External Source And Parse It

Dec 7, 2011

Part of my project is to retrieve a string variable from an external source (google docs) and parse it. This string represents width and height. I have no problem retrieving, I just need to parse it in to two strings. The string has 4 variations.

Here are examples:
3"x4"
3"hx4"w
3hx4w
3x4

The width is always the first number and the height is always the second. Sometimes, the width and height have decimal points. Any way to parse this into two strings of the numeric values only?

View 3 Replies

Regex - Regular Expression To Parse Whitespace-delimited Data?

Jun 18, 2009

I have written code to pull some data into a data table and do some data re-formatting. I need some help splitting some text into appropriate columns.

CASE 1

I have data formated like this that I need to split into 2 columns.

[Code]...

column is the first 11 characters That is easy.column 2 should contain all the text after the first 11 characters up to but not including the first number.The last column is all the text after column 2

View 4 Replies

VS 2008 Regex - Parse Out Some Links Via Search And Fill A Text Box With Said Results

Mar 25, 2009

What I'm trying to do is parse out some links via a google search and fill a text box with said results. This is the code I have in a module which I call upon inside of a command button.

Imports System.Text
Imports System.Text.RegularExpressions

Module Module1

[CODE]...

View 8 Replies

Extract Specific Texts From Parse Given Header Names

Feb 6, 2010

I have a parse from Wikipedia saved in a text file in the following form: The town itself is situated to the south-east of the rock, and overlooks the Palaia Monemvasia bay. A small hamlet with about 10 houses lies to the northwest.The founding of the town and fortress of Monemvassia most probably occurred in the 6th century AD. The town was founded in 583 by people seeking refuge from the [[Slavic peoples|Slavic]] and the [[Eurasian Avars|Avaric]] invasion of Greece. From the 10th century AD, the town developed into an important trade and maritime centre. The fortress withstood the [[Arab]] and [[Normans|Norman]] invasions and conquests in 1147. Cornfields that fed up to 30 men were grown inside the fortress.What I need to do is to extract specific texts from the parse given the header names. For example, if I type in a textbot Geography I need ONLY the geography text returned.

View 8 Replies

Double.Parse % Percent - Input String Was Not In A Correct Format

Jan 19, 2010

I have a DGV with a column bound to a Double. When I enter "1%" I get:

System.FormatException: Input string was not in a correct format.

I then try: MsgBox(System.Double.Parse("1%")) and get essentially the same error. (same for "$")

Is there a setting that will allow "$" & "%" as not only valid Double input but also do the correct adjustment for "%"?

View 2 Replies

Regex - ASP Regular Expression For UK Telephone Format?

Sep 23, 2009

I want regular expression validator for my telephone field in VB.net. Telephone format should be (+)xx-(0)xxxx-xxxxxx ext xxxx (Optional) example my number would appear as 44-7966-591739 Screen would be formatted to show +44-(0)7966-591739 ext?

View 3 Replies

Regex - Verifying The Format Of A Text File?

Feb 9, 2011

I have an application that downloads a .txt file via FTP, and then it calls some sql to insert the file data into my database. I want to check whether the file is in the correct format before trying to insert.

The file should consist of some number of rows, each with the following format:

(4 letter code) (tab) (3 or 4 letter code) (tab) (date as dd-MMM-yy) (tab) (variable length text description) (tab) (1 letter code)

Is there a good way to check whether every line in the file follows this pattern, and warn me if it doesn't?

View 1 Replies

Matching A Specific File Name Structure With Regex?

Jun 21, 2011

Regex in VB2008.I have a file system directory that my code is watching. When a file is placed in that directory my code kicks off a processing application. Based on the filename structure, the code will perform different processes. So I need to match the filename structure specficially to get the correct processes to run on that file.My file name structure is: IK2YYYYMMDD_VV.e;where YYYYMMDD is well, the year, month and day. And VV is a verison number from 00-99 If the new file saved in the directory match this structure then I want a TRUE returned. From a filewatcher I get the filename as an "e.Name" (FileSystemEventArgs) variable. My current code to see if it matches the baseline structure is;

Dim IKPred2Match as New Regex ("^IK2.*\.e$") Dim ValidIKPred2Match as MatchCollection = IKPred2Match.Matches(e.Name)I've tried many different regex match patterns, and just can't seem to find the magic one.

View 2 Replies

Regex - Regular Expression With Specific Criteria

Jan 31, 2011

I'm trying to type a regular expression that follows the following format: [URL] There are no special characters or numbers permitted for this criteria. I thought I had it down, but I'm a bit rusty with regular expressions and when I tested mine, it failed all across the boards. So far, my regular is expression is:

[Code]...

View 3 Replies

VS 2010 Put More Lines For Specific Information Of Regex?

Nov 6, 2009

How do i can put more lines for specific information of regex?

...Regex("(?<=SOMETHING).+?(?=SOMETHING)")

Once again selected from RuneScape, because here is best code for it.

<tr class="row rowp4">
<td align="center">
<img class="miniimg" src="http://www.runescape.com/img/hiscores/skill_icon_strength1.gif">
</td>

[code]....

View 3 Replies

Parse Excel Formula "=a(b,c,d)" With Regex?

Dec 23, 2010

I am trying to parse the parameters of Excel formulas like "=a(b)", "=a(b,c)", "=a(b,c,d)". I'd like extract the function name "a" and the parameters "b", "c" and "d".

There are loads of examples on SO to parse HTML and so forth, but none specifically for parentheses.

So far, I've got this "=(.+)(([^,)]*)(,[^,)]*)*)" but when I parse "=a(b,c,d)" it puts "a" in match(1), "b" in match(2) and ",d" in match(3). So "c" is lost and the comma before the "d" is a pain.

How can I parse a string like this with an arbitrary number of parameters, ideally dropping the commas?

The ability to parse "=a(b(c),d(e(f)))" would be great...

Edit: I know that a parser is the correct solution and I have used Devin Cook's excellent Gold Parser with great results before.

However, the particular case I'm facing is to extract the arguments from a known Excel formula. Specifically, if the formula contains the string "=Travel(", I know that it will have 4 arguments and if they don't parse it's not a problem. This is simply a "nice to have" function which can fail occasionally without it being an issue.

regex for "=a(b,c,d)", "=a(b,c,d,e)", etc., with the constraint that there will be no nested parentheses or commas?

View 1 Replies

Twitter Json - Unable To Convert To Jobject Or Jarray Using Json.net / Javascriptserializer?

May 9, 2012

I am been stuck on this for 3 days now...I have been accessing the twitter api to pull a user_timeline for a list of users and the json that comes back is impossible to work with. I tried to deserialize it using javascriptserializer and get an error:invalid object passed in , ':' or '}'

Now this is frustrating since I expect the json being returned to be error free. Then I tried json.net and split the posts using string.split and tried to convert each post to Jobject or jarray. for Jarray I get

'unexpected end of content while loading jArray

[Code]...

Now I have formatted the code here and not pasted the whole file but it does look like valid json to me and I do not alter anything after receiving the stream from the twitter api. Can someone please point me in the right direction? I really need to get this stuff parsed?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved