{"id":13413889,"url":"https://github.com/jfilipczyk/gomatch","last_synced_at":"2025-03-14T20:30:46.730Z","repository":{"id":49326831,"uuid":"167854148","full_name":"jfilipczyk/gomatch","owner":"jfilipczyk","description":"Library created for testing JSON against patterns.","archived":false,"fork":false,"pushed_at":"2021-01-15T13:14:48.000Z","size":36,"stargazers_count":46,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T20:52:57.678Z","etag":null,"topics":["bdd","golang","json","matcher","pattern-matching","tdd","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jfilipczyk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-27T20:19:06.000Z","updated_at":"2024-03-04T06:42:48.000Z","dependencies_parsed_at":"2022-09-26T19:53:34.045Z","dependency_job_id":null,"html_url":"https://github.com/jfilipczyk/gomatch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfilipczyk%2Fgomatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfilipczyk%2Fgomatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfilipczyk%2Fgomatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfilipczyk%2Fgomatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jfilipczyk","download_url":"https://codeload.github.com/jfilipczyk/gomatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243642002,"owners_count":20323947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bdd","golang","json","matcher","pattern-matching","tdd","testing"],"created_at":"2024-07-30T20:01:52.059Z","updated_at":"2025-03-14T20:30:46.424Z","avatar_url":"https://github.com/jfilipczyk.png","language":"Go","readme":"# Gomatch\n\n\u003cimg align=\"right\" width=\"147px\" src=\"https://raw.github.com/jfilipczyk/gomatch/master/logo.png\"\u003e\n\n[![Build Status](https://travis-ci.com/jfilipczyk/gomatch.svg?branch=master)](https://travis-ci.com/jfilipczyk/gomatch)\n[![codecov](https://codecov.io/gh/jfilipczyk/gomatch/branch/master/graph/badge.svg)](https://codecov.io/gh/jfilipczyk/gomatch)\n[![GoDoc](https://godoc.org/github.com/jfilipczyk/gomatch?status.svg)](https://godoc.org/github.com/jfilipczyk/gomatch)\n[![Go Report Card](https://goreportcard.com/badge/github.com/jfilipczyk/gomatch)](https://goreportcard.com/report/github.com/jfilipczyk/gomatch)\n\nLibrary created for testing JSON against patterns. The goal was to be able to validate JSON focusing only on parts essential in given test case so tests are more expressive and less fragile. It can be used with both unit tests and functional tests.\n\nWhen used with Gherkin driven BDD tests it makes scenarios more compact and readable. See [Gherkin example](#gherkin-example)\n\n## Contests\n\n  - [Installation](#installation)\n  - [Basic usage](#basic-usage)\n  - [Available patterns](#available-patterns)\n  - [Gherkin example](#gherkin-example)\n  - [License](#license)\n  - [Credits](#credits)\n\n## Installation\n\n```shell\ngo get github.com/jfilipczyk/gomatch\n```\n\n## Basic usage\n\n```go\n\nactual := `\n{\n  \"id\": 351,\n  \"name\": \"John Smith\",\n  \"address\": {\n    \"city\": \"Boston\"\n  }\n}\n`\nexpected := `\n{\n  \"id\": \"@number@\",\n  \"name\": \"John Smith\",\n  \"address\": {\n    \"city\": \"@string@\"\n  }\n}\n`\n\nm := gomatch.NewDefaultJSONMatcher()\nok, err := m.Match(expected, actual)\nif ok {\n  fmt.Printf(\"actual JSON matches expected JSON\")\n} else {\n  fmt.Printf(\"actual JSON does not match expected JSON: %s\", err.Error())\n}\n\n```\n\n## Available patterns\n\n* `@string@`\n* `@number@`\n* `@bool@`\n* `@array@`\n* `@uuid@`\n* `@email@`\n* `@wildcard@`\n* `@...@` - unbounded array or object\n\n### Unbounded pattern\n\nIt can be used at the end of an array to allow any extra array elements:\n```json\n[\n  \"John Smith\",\n  \"Joe Doe\",\n  \"@...@\"\n]\n```\n\nIt can be used at the end of an object to allow any extra keys:\n```json\n{\n  \"id\": 351,\n  \"name\": \"John Smith\",\n  \"@...@\": \"\"\n}\n```\n\n## Gherkin example\n\nGomatch was created to use it together with tools like [GODOG](https://github.com/DATA-DOG/godog).\nThe goal was to be able to validate JSON response focusing only on parts essential in given scenario.\n\n```gherkin\nFeature: User management API\n  In order to provide GUI for user management \n  As a frontent developer\n  I need to be able to create, retrive, update and delete users\n\n  Scenario: Get list of users sorted by username ascending\n    Given the database contains users:\n    | Username   | Email                  |\n    | john.smith | john.smith@example.com |\n    | alvin34    | alvin34@example.com    |\n    | mike1990   | mike.jones@example.com |\n    When I send \"GET\" request to \"/v1/users?sortBy=username\u0026sortDir=asc\"\n    Then the response code should be 200\n    And the response body should match json:\n    \"\"\"\n    {\n      \"items\": [\n        {\n          \"username\": \"alvin34\",\n          \"@...@\": \"\"\n        },\n        {\n          \"username\": \"john.smith\",\n          \"@...@\": \"\"\n        },\n        {\n          \"username\": \"mike1990\",\n          \"@...@\": \"\"\n        }\n      ],\n      \"@...@\": \"\"\n    }\n    \"\"\"\n```\n\n## License\n\nThis library is distributed under the MIT license. Please see the LICENSE file.\n\n## Credits\n\nThis library was inspired by [PHP Matcher](https://github.com/coduo/php-matcher)\n\n### Logo\nThe Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/).\nGomatch logo was based on a gopher created by Takuya Ueda (https://twitter.com/tenntenn). Licensed under the [Creative Commons 3.0 Attributions license](http://creativecommons.org/licenses/by/3.0/deed.en). Gopher eyes were changed.","funding_links":[],"categories":["Testing","测试","测试相关","Go","Template Engines","Testing Frameworks","测试相关`测试库和测试数据集生成库`"],"sub_categories":["Testing Frameworks","HTTP客户端","查询语","HTTP Clients"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfilipczyk%2Fgomatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjfilipczyk%2Fgomatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfilipczyk%2Fgomatch/lists"}