Click here to Skip to main content
15,888,908 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Excel VBA For Loop Weighted Average Pin
Kenneth Haugland29-Feb-16 23:50
mvaKenneth Haugland29-Feb-16 23:50 
GeneralRe: Excel VBA For Loop Weighted Average Pin
Member 122655371-Mar-16 0:27
Member 122655371-Mar-16 0:27 
GeneralRe: Excel VBA For Loop Weighted Average Pin
Kenneth Haugland1-Mar-16 11:13
mvaKenneth Haugland1-Mar-16 11:13 
QuestionNet.Sockets.TcpListener Pin
hansoctantan29-Feb-16 1:40
professionalhansoctantan29-Feb-16 1:40 
QuestionRe: Net.Sockets.TcpListener Pin
Eddy Vluggen29-Feb-16 2:41
professionalEddy Vluggen29-Feb-16 2:41 
AnswerRe: Net.Sockets.TcpListener Pin
Dave Kreskowiak29-Feb-16 3:55
mveDave Kreskowiak29-Feb-16 3:55 
Questionjson exception Pin
duup27-Feb-16 0:43
duup27-Feb-16 0:43 
AnswerRe: json exception Pin
Dave Kreskowiak27-Feb-16 10:49
mveDave Kreskowiak27-Feb-16 10:49 
It doesn't work because you're not deserializing a complete JSON document. You're actually trying to is deserialize a list of JSON fragments. You have to process this one line at a time, not all at once.

Given the identifier names in the JSON file are very short, you'd probably be better off creating a strongly typed class so you can map those short names to something more friendly in your code.

The code snippets are in C#, but are EASILY converted to VB.NET. I'm just too lazy to do it for you.
C#
private IList<ZipCodeData> ProcessFile(string filepath)
{
    using (var sr = File.OpenText(filepath))
    {
        List<ZipCodeData> objects = new List<ZipCodeData>();

        var lineContent = sr.ReadLine();

        while (!string.IsNullOrEmpty(lineContent))
        {
            var obj = JsonConvert.DeserializeObject<ZipCodeData>(lineContent);

            objects.Add(obj);

            lineContent = sr.ReadLine();
        }

        return objects;
    }
}


The ZipCodeData class looks like this:
C#
public class ZipCodeData
{
    [JsonProperty("city")]
    public string City { get; set; }

    [JsonProperty("loc")]
    public double[] Location { get; set; }

    [JsonProperty("pop")]
    public int Population { get; set; }

    [JsonProperty("state")]
    public string State { get; set; }

    [JsonProperty("_id")]
    public string Zip { get; set; }
}

A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

GeneralRe: json exception Pin
duup28-Feb-16 21:04
duup28-Feb-16 21:04 
GeneralRe: json exception Pin
Dave Kreskowiak29-Feb-16 2:41
mveDave Kreskowiak29-Feb-16 2:41 
Questionhow to start a vbs script in a vbs script on a client computer Pin
Member 1191673523-Feb-16 22:31
Member 1191673523-Feb-16 22:31 
AnswerRe: how to start a vbs script in a vbs script on a client computer Pin
Dave Kreskowiak24-Feb-16 2:16
mveDave Kreskowiak24-Feb-16 2:16 
GeneralRe: how to start a vbs script in a vbs script on a client computer Pin
Member 1191673524-Feb-16 3:39
Member 1191673524-Feb-16 3:39 
GeneralRe: how to start a vbs script in a vbs script on a client computer Pin
Dave Kreskowiak24-Feb-16 3:58
mveDave Kreskowiak24-Feb-16 3:58 
GeneralRe: how to start a vbs script in a vbs script on a client computer Pin
Member 1191673525-Feb-16 0:58
Member 1191673525-Feb-16 0:58 
GeneralRe: how to start a vbs script in a vbs script on a client computer Pin
Dave Kreskowiak25-Feb-16 1:42
mveDave Kreskowiak25-Feb-16 1:42 
QuestionStarting the process as user will not work on Win2012 Pin
byka23-Feb-16 1:29
byka23-Feb-16 1:29 
AnswerRe: Starting the process as user will not work on Win2012 Pin
Dave Kreskowiak23-Feb-16 4:06
mveDave Kreskowiak23-Feb-16 4:06 
GeneralRe: Starting the process as user will not work on Win2012 Pin
byka23-Feb-16 5:13
byka23-Feb-16 5:13 
GeneralRe: Starting the process as user will not work on Win2012 Pin
Dave Kreskowiak23-Feb-16 5:16
mveDave Kreskowiak23-Feb-16 5:16 
GeneralRe: Starting the process as user will not work on Win2012 Pin
byka23-Feb-16 7:14
byka23-Feb-16 7:14 
GeneralRe: Starting the process as user will not work on Win2012 Pin
Dave Kreskowiak23-Feb-16 8:14
mveDave Kreskowiak23-Feb-16 8:14 
GeneralRe: Starting the process as user will not work on Win2012 Pin
Eddy Vluggen23-Feb-16 8:35
professionalEddy Vluggen23-Feb-16 8:35 
GeneralRe: Starting the process as user will not work on Win2012 Pin
Dave Kreskowiak23-Feb-16 9:01
mveDave Kreskowiak23-Feb-16 9:01 
QuestionProblem with receiving UDP from AVR microcontroller Pin
Mototest22-Feb-16 7:35
Mototest22-Feb-16 7:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.