hurwitzlab/robotframework-jsonlibrary

Name: robotframework-jsonlibrary

Owner: Hurwitz Lab

Description: Robotframework Test Library to manipulate JSON using JSONPath

Forked from: nottyo/robotframework-jsonlibrary

Created: 2018-01-26 21:02:00.0

Updated: 2018-01-26 21:02:02.0

Pushed: 2018-01-26 21:50:13.0

Homepage:

Size: 71

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

robotframework-jsonlibrary

JSONLibrary is a Robot Framework test library for manipulating JSON Object. You can manipulate your JSON object using JSONPath

JSONPath is an expression which can help to access to your JSON document. The JSONPath structure is in the same way as XPath which use for accessing XML document. This is an example of JSONPath syntax.

| JSONPath | Description | |———-|————-| | $ | the root object/element | | @ | the current object/element | | . or [] | child operator | | .. | recursive descent. JSONPath borrows this syntax from E4X | | * | wildcard. All objects/element regardless their names. | | [] | subscript operator. XPath uses it to iterate over element collections and for predicates. In Javascript and JSON it is the native array operator. | | [,] | Union operator in XPath results in a combination of node sets. JSONPath allows alternate names or array indices as a set. | | [start\: end\: step] | array slice operator borrowed from ES4 | | ?() | applies a filter (script) expression. | | () | script expression, using the underlying script engine. |

This library can help you to add, get, update and delete your JSON object. So it's very useful in case that you have a very large JSON object.

Usage

Install robotframework-jsonlibrary via pip command

install -U robotframework-jsonlibrary

Example Test Case

Settings | | | | | —————– |——————– |—————– |———– |—————– | Library | JSONLibrary | | | | Test Cases | | | | | ${json_obj}= | Load JSON From File | example.json | | | ${object_to_add}= | Create Dictionary | country=Thailand | | | ${json_obj}= | Add Object To Json | ${json_obj} | $..address | ${object_to_add} | ${value}= | Get Value From Json | ${json_obj} | $..country | | |Should Be Equal As Strings | ${value[0]} | Thailand | | | |${value_to_update}=| Set Variable | Japan | | | |${json_obj}= | Update Value To Json | ${json_obj} | $..country | ${value_to_update}| |Should Be Equal As Strings | ${json_obj['country'] | ${value_to_update} | | |

Documentation

For the detail keyword documentation. Go to this following link:

https://nottyo.github.io/robotframework-jsonlibrary/

Help & Issues

Mention me on Twitter @nottyo


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.