ABAP JSONPath

ABAP JSONPath

99.00 (incl. 0% Tax) on the 1st of each month and a 399.00 (incl. 0% Tax) sign-up fee

This product is sold by Blue Antoinette Business Solutions.

Get our ABAP JSONPath implementation that we developed in the YouTube Video ABAP JSONPath.  With your subscription we develop it further and provide you with updates.
See a real world example of ABAP JSONPath in this video.

Subscription Plans:

  • 1 Subscription entitles you to use this solution for one developer seat.
  • Minimum renewal period is 3 months
  • Updates require an active subscription

Number of  Developer Seats:

First payment: January 1, 2025

Categories: , Tags: ,

Product Description

ABAP JSONPath files:

Included files:

zcl_jsonpath.aclass (ABAP JSONPath Class)
zcl_test.aclass (Executable ABAP Test Class)

You can import these files with Eclipse into your ABAP Environment.

Example JSON string (used in the description below):

{
  "bookstore": "My Bookstore",
  "address": {
    "street": "900 Lombard Street",
    "city": "San Francisco",
    "zipcode": "94133"
   },
  "book": [
    {
      "title": "English Book",
      "author": "English Author"
    },
    {
     "title": "French Book",
     "author": "French Author"
    }
  ]
}

ABAP JSONPath currently supported features:

ABAP JSONPath notation

Dot notation: E.g. $.book[0].title

ABAP JSONPath expressions

Expression Description Sample Sample Result
$ The root object or array $
$.property Selects the specified property in a parent object $.bookstore My Bookstore
$.property[n] Selects the n-th element from an array. Indexes are 0-based $.book[1] { “title”: “French Book”, “author”: “French Author”}
$.property1[n].property2 Selects the property2 from the n-th element of the property1 array. Indexes are 0-based $.book[1].title French Book
$.property[*] Wildcard selects all elements in an array, regardless of their names or indexes $.book[*] [{“author”:”English Author”,”title”:”English Book”},{“author”:”French Author”,”title”:”French Book”}]
$.property1[*].property2 Selects all property2-s in all elements of property1 array. $.book[*].title [English Book,French Book]

ABAP JSONPath Public Methods

Public Instance Methods Description
set IMPORTING json_string TYPE string Sets the json string
get IMPORTING query_string TYPE string RETURNING VALUE(r_value) TYPE string Returns the result string
get_ref_data IMPORTING query_string TYPE string RETURNING value(r_result) TYPE REF TO data Returns a reference to the result data
get_data IMPORTING query_string TYPE string CHANGING data TYPE data Provides the result in the requested data structure
Public Class Methods Description
query IMPORTING json_string TYPE /ui2/cl_json=>json query_string TYPE string Sets the json string and returns the result string at once

ABAP JSONPath Public Instance Methods Sample Calls

Get string result Result String
DATA: json_string TYPE string,
      query_string TYPE string,
      result TYPE string.

json_string = `Example JSON string from above`.
query_string = `$.book[*].title`.

DATA(jsonpath) = NEW ZCL_JSONPATH( ).
jsonpath->set( json_string ).
result = jsonpath->get( query_string = query_string ).

out->write( result ).
[English Book,French Book]
Get reference to result data Result Reference
 DATA: json_string TYPE string,
 query_string TYPE string,
 result TYPE string,
 ref_data TYPE REF TO data.

 FIELD-SYMBOLS:
 <data> TYPE data,
 <field> TYPE any.

 json_string = ``.
 query_string = `$.address`.

 DATA(jsonpath) = NEW ZCL_JSONPATH( ).
 jsonpath->set( json_string ).
 ref_data = jsonpath->get_ref_data( query_string = query_string ).

 ASSIGN ref_data->* TO <data>.
 out->write( <data> ).
CITY->*       STREET->*          ZIPCODE->*
San Francisco 900 Lombard Street 94133
Get structured result in predefined table Result Table
TYPES:
  BEGIN OF ts_data,
    title TYPE string,
    author TYPE string,
  END OF ts_data,
  tt_data TYPE STANDARD TABLE OF ts_data WITH EMPTY KEY.

 DATA: my_typed_data TYPE tt_data.

 DATA: json_string TYPE string,
       query_string TYPE string,
       result TYPE string.

 json_string = `Example JSON string from above`.
 query_string = `$.book[*]`.

 DATA(jsonpath) = NEW ZCL_JSONPATH( ).
 jsonpath->set( json_string ).
 jsonpath->get_data( EXPORTING query_string = query_string CHANGING data = my_typed_data ).
 out->write( my_typed_data ).
TITLE        AUTHOR
English Book English Author
French Book  French Author

Liability

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Seller Information