{"id":18861244,"url":"https://github.com/simplydemo/json-sql-demo","last_synced_at":"2026-02-09T09:30:16.883Z","repository":{"id":248127154,"uuid":"827288099","full_name":"simplydemo/json-sql-demo","owner":"simplydemo","description":"This is easily access JSON messages through SQL query expressions.","archived":false,"fork":false,"pushed_at":"2024-07-15T08:14:41.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T20:27:59.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplydemo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-11T11:04:07.000Z","updated_at":"2024-07-15T08:14:44.000Z","dependencies_parsed_at":"2024-07-12T15:34:58.110Z","dependency_job_id":"1ec3c440-e86c-453f-b7bb-18cd14671d23","html_url":"https://github.com/simplydemo/json-sql-demo","commit_stats":null,"previous_names":["simplydemo/json-sql-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplydemo%2Fjson-sql-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplydemo%2Fjson-sql-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplydemo%2Fjson-sql-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplydemo%2Fjson-sql-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplydemo","download_url":"https://codeload.github.com/simplydemo/json-sql-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239800495,"owners_count":19699150,"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":[],"created_at":"2024-11-08T04:28:48.964Z","updated_at":"2026-02-09T09:30:16.848Z","avatar_url":"https://github.com/simplydemo.png","language":"Java","readme":"# json-sql-demo\n\nThis is easily access JSON messages through SQL query expressions.\n\n## Usage\n\n### Query Json and convert to Map type\n\n```java\npublic void testCase() {\n    String json = \"\"\"\n              {\n                \"id\": \"668feca3b450e6d8f583b561\",\n                \"index\": 0,\n                \"guid\": \"704a409d-e95d-4aca-bd46-782d050a9b77\",\n                \"isActive\": false,\n                \"age\": 39,\n                \"name\": \"Long Phillips\",\n                \"email\": \"longphillips@imant.com\",\n                \"registered\": \"2022-07-18T04:35:17 -09:00\"\n              }\n            \"\"\";\n    String sql = \"select  id, index, guide, isActive, age from USER\";\n    SqlSession sqlSession = new SqlSession(new JsonQueryHandler(\"USER\", json));\n    Map\u003cString, Object\u003e data = sqlSession.queryForObject(sql, Map.of());\n    System.out.println(data);\n}\n```\n\n### Query Json and convert to List type\n\n```java\npublic void testCase() {\n    String json = \"\"\"\n                [\n                  {\n                    \"id\": \"668ff4482965ffc5acb09c08\",\n                    \"index\": 2,\n                    \"guid\": \"dc9bb694-3a10-4005-9d91-c89bdca03ea3\",\n                    \"isActive\": true,\n                    \"age\": 20,\n                    \"name\": \"Manuela Olson\",\n                    \"email\": \"manuelaolson@zenthall.com\",\n                    \"registered\": \"2017-06-27T04:40:15 -09:00\"\n                  },\n                  {\n                    \"id\": \"668ff4482abed548eb94913f\",\n                    \"index\": 3,\n                    \"guid\": \"fb439ae2-5962-4eb9-8349-661687f3eb69\",\n                    \"isActive\": true,\n                    \"age\": 31,\n                    \"name\": \"Rodgers Carr\",\n                    \"email\": \"rodgerscarr@brainquil.com\",\n                    \"registered\": \"2019-01-30T03:59:21 -09:00\"\n                  }\n                ]\n            \"\"\";\n    String sql = \"\"\"\n                    select  id, index, guid, isActive, age, \n                    name, email, registered\n            from    user \n            where   age = :age \n            \"\"\";\n    SqlSession sqlSession = new SqlSession(new JsonQueryHandler(\"user\", json));\n    List\u003cMap\u003c?, Object\u003e\u003e records = sqlSession.queryForList(sql, Map.of(\"age\", 30));\n    records.forEach(System.out::println);\n    assertEquals(2, records.size());\n}\n```\n\n### Get the name of json attributes\n\nGet the names of json properties by identifying them according to the hierarchy.\n\n```java\npublic void testCase() {\n    String json = \"\"\"\n                {\n                  \"id\": \"668feca3b450e6d8f583b561\",\n                  \"index\": 0,\n                  \"guid\": \"704a409d-e95d-4aca-bd46-782d050a9b77\",\n                  \"isActive\": false,\n                  \"age\": 39,\n                  \"name\": \"Long Phillips\",\n                  \"email\": \"longphillips@imant.com\",\n                  \"registered\": \"2022-07-18T04:35:17 -09:00\",\n                  \"detail\": {\n                      \"category\": \"issue\",\n                      \"code\": \"APPLE101\",\n                      \"communicationId\": \"1234abc01232a4012345678-1\"\n                  }\n                }\n            \"\"\";\n    String sql = \"select id, guid, isActive, name, email from USER where id = '668feca3b450e6d8f583b561'\";\n    SqlSession sqlSession = new SqlSession(new JsonQueryHandler(\"user\", json));\n    System.out.println(\"keys: \" + sqlSession.getKeys());\n    System.out.println(\"keys: \" + sqlSession.getKeys(2));\n}\n```\n\n## What to do First?\n\nTo use [json-sql](https://github.com/thenovaworks/json-sql.git), simply add a dependency to your Maven or Gradle project.\n\n- Maven\n\n```xml\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.github.thenovaworks\u003c/groupId\u003e\n        \u003cartifactId\u003ejson-sql\u003c/artifactId\u003e\n        \u003cversion\u003e1.0.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n- Gradle\n\n```groovy\ndependencies {\n    implementation 'io.github.thenovaworks:json-sql:1.0.0'\n}\n```\n\n## References\n\n- [json-sql](https://github.com/thenovaworks/json-sql.git)\n- [mvn-repository](https://mvnrepository.com/)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplydemo%2Fjson-sql-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplydemo%2Fjson-sql-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplydemo%2Fjson-sql-demo/lists"}