Showing posts with label JSON. Show all posts

Excel Power Query - Load JSON as a table

by GarciaPL on Sunday, 18 February 2018

If you would like to load JSON and present it as a table, it's quite easy if you have an Excel 2016 [1]. It's more complicated, once you have a lower version.

First of all, try to install an additional plugin called Power Query [2].

In the Power Query ribbon tab, click From Other Sources > Blank Query, then go to Advanced Editor and input below query string. Do not forget to change the path to your JSON.

Click -> Close & Load

let

Source = Json.Document(File.Contents("Z:\Directory\input.json")),
AsTable = Table.FromRecords(Source)

in

AsTable

Click on 'Close & Load'
Reference :
[1] Microsoft Support - Connect to a JSON file
[2] Power Query for Excel

Browser User Agents (JSON)

by GarciaPL on Saturday, 16 January 2016

Below you can find GitHub Gist of User Agents in JSON based on massive list of user agents provided by Chris Pederik [1]. I provided the same list of user agents in more friendly form as a JSON because of this one provided in reference is nested multiple times, what obviously affects the use of content. Moreover I removed duplicates.





Reference : [1] https://gist.github.com/enginnr/ed572cf5c324ad04ff2e

Maven Fetch JSON during building Jar

by GarciaPL on Monday, 25 May 2015

My recent project was aimed to develop standalone application written in Swing with embedded database which was in form of JSON file. During building my Jar using Maven, I was faced with problem to replace this JSON file before final application will be produced. Before you will prepare such solution you should get familiar with Maven Build Lifecycle [1]. Below I listed those LifeCycle's :


  1. validate
  2. generate-sources
  3. process-sources
  4. generate-resources
  5. process-resources
  6. compile
  7. process-classes
  8. generate-test-sources
  9. process-test-sources
  10. generate-test-resources
  11. process-test-resources
  12. test-compile
  13. test
  14. prepare-package (maven 2.1+)
  15. package
  16. pre-integration-test
  17. integration-test
  18. post-integration-test
  19. verify
  20. install
  21. deploy
After you will decide in which phase you are going to run your custom Java class, which in my case was fetching JSON from server, you are going to use plugin called exec-maven-plugin developed by Codehaus [2].

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <id>fetchJSON</id>
                        <phase>prepare-package</phase>
                        <inherited>false</inherited>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>pl.avantis.iom.rest.DrupalQueriesImpl</mainClass>
                    <cleanupDaemonThreads>true</cleanupDaemonThreads>
                    <daemonThreadJoinTimeout>30000</daemonThreadJoinTimeout>
                </configuration>
            </plugin>

This plugin will run pl.avantis.iom.rest.DrupalQueriesImpl in phase prepare-package, this is a step just before package phase, so your Jar will contain the newest JSON file without downloading it manually .

Reference : [1] Maven Build Lifecycle [2] Codehaus - Exec Maven Plugin