HTTP Client 4 and a JSON endpoint

August 17, 2017

I need to POST to a HTTPS JSON based service endpoint in Java. I can do this using Http Client 4.

In the following code, SERVICE_ENDPOINT is the full URL to the service, in my case https://" + SERVICE_HOST + "/v2/. The other values should be self explanatory, and are all strings ...

Parse JSON with Jackson

August 17, 2017

I wanted to parse a small JSON response message in Java, using the Jackson library - version 2.4.5.

The code is as follows, where pJsonResponse is the passed in JSON to parse:

ObjectMapper lMapper = new ObjectMapper();
JsonNode lParsedValue;
  lParsedValue = lMapper.readTree(pJsonResponse);
catch (IOException lException)
  throw new RuntimeException ...

Mac, DotNetCore, Postgres

July 29, 2017

I'm having fun trying to get an application that was originally developed on Windows, against SQL Server, running on a Mac against Postgres. It's written in Microsoft's dotnet core, using C# and Entity Framework Core.

The solution has multiple projects inside of it:

  • Salon - contains the web ...

LINQ Reference

July 21, 2017

Find items in list that matching condition

bool lHasAccepted = ItemsList.Any(itm => itm.IsAccepted.HasValue && itm.IsAccepted.Value == true);

Filter and count items in list

int lAcceptedCount = ItemsList.Where(itm => itm.IsAccepted.HasValue && itm.IsAccepted.Value == true).Count();

Convert Type and map

return await this.dbContext.Submissions.Where(sub => sub ...

Tags: linq

Row Counts in Postgres

July 18, 2017

Here's a query that will give an estimate of the rows in all tables of a postgres database.

SELECT schemaname,relname,n_live_tup 
FROM pg_stat_user_tables 
ORDER BY n_live_tup DESC;