JSON Path

Content Type: Module
Categories: Import/Export

Overview

JSONPath = XPath for JSON A JSONPath implementation based on Jayway JsonPath java library (https://github.com/json-path/JsonPath).

Documentation

JSON-Path-module

Description

A JSONPath implementation based on the Jayway JsonPath java library (https://github.com/json-path/JsonPath).

Typical usage scenario

When JSON structures are nested it is not always convenient to use import mappings, because each level of nesting means that unnecessary entities and associations need to be added to the domain model. This module contains java actions for retrieving single values from a json structure as well as nested json objects and arrays that can be used in a import mappings.

  • Retrieving / Finding simple values from a (nested) JSON structure.
    • Strings, Integers, Decimals, Booleans
  • Retrieving JSON structures in a nested JSON structure
    • JSON Objects & Arrays (returned as Strings)
  • Using the JSONPath Syntax for filter results (e.g. filtering json before applying a import mapping)
    • Features and limitations

Available Microflow actions:

GetStringFromJSONByPath

  • Returns first String value from a JSON input matching JSONPath expression
  • Returns empty if not found or result is not String

GetBooleanFromJSONByPath

  • Returns first Boolean* value from a JSON input matching JSONPath expression
  • Returns empty if not found or result is not Boolean

GetIntegerFromJSONByPath

  • Returns first Integer value from a JSON input matching JSONPath expression
  • Returns empty if not found or result is not Integer/Long

GetDecimalFromJSONByPath

  • Returns first Decimal value from a JSON input matching JSONPath expression
  • Returns empty if not found or result is not numeric (Integer, Decimal, etc.)

GetJSONObjectFromJSONByPath

  • Returns JSON Object String from a JSON input matching JSONPath expression
  • Returns empty if not found or result is not a JSON Object

GetJSONArrayFromJSONByPath

  • Returns JSON Array String from a JSON input matching JSONPath expression
  • Returns empty if not found or result is not a JSON Array

*Does not actually return a Boolean, but an enumeration with _true & _ false values as Mendix does not support empty booleans

Resources

JSON Path Online Evaluator (for testing JSON Path expressions) http://jsonpath.com JSONPath Java Library Github https://github.com/json-path/JsonPath

Upgrading to a higher version

When upgrading to a higher version, delete any outdated .jar and .JSONPath.RequiredLib in your project's userlib folder linked to older versions of the module.

Note: Starting with version 2.0.0 .JSONPath.RequiredLib files will include the version number of the module, for example: json-smart-2.4.7.jar.JSONPath-2.0.0.RequiredLib

Developer Notes

Before publishing a new version of the module, increase the version numbers in the Mendix module, install-dependencies.sh and pom.xml and run install-dependencies.sh to update the userlib folder.

Frequently Asked Questions

Q: What is JSONPath? A: It's like XPath for JSON

Releases

Version: 2.1.0
Framework Version: 9.24.24
Release Notes: * upgraded Mendix version to 9.24.24 LTS
Version: 2.0.3
Framework Version: 8.18.30
Release Notes: * upgraded JSON Path library to 2.9.0 to fix security vulnerability * upgraded JSON Smart library to 2.5.1
Version: 2.0.2
Framework Version: 8.18.6
Release Notes: - patched JSON smart to 2.4.10 to fix vulnerability
Version: 2.0.1
Framework Version: 8.18.6
Release Notes: - re-release of v2.0.0
Version: 2.0.0
Framework Version: 8.18.6
Release Notes: - Upgraded to Mendix 8.18.6 - Updated Java dependencies & cleaned up unnecessary dependencies - Included a Maven file for better dependency management - Replaced Mendix project in the Git repository and added JSON path evaluator UI
Version: 1.1.0
Framework Version: 7.23.7
Release Notes: Fixed long parsing issue
Version: 1.0.1
Framework Version: 7.23.7
Release Notes: Upgraded to 7.23.7
Version: 1.0.0
Framework Version: 7.13.1
Release Notes: Initial Release