{"id":31943605,"url":"https://github.com/dancecoder/json22-axios","last_synced_at":"2025-10-14T09:59:19.130Z","repository":{"id":57285504,"uuid":"458484889","full_name":"dancecoder/json22-axios","owner":"dancecoder","description":"Axios interceptor providing support to JSON22 data format in your applications.","archived":false,"fork":false,"pushed_at":"2022-02-13T10:59:45.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-01-28T17:01:56.955Z","etag":null,"topics":["axios","axios-middleware","axios-plugin","json22","serialization-format"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/dancecoder.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}},"created_at":"2022-02-12T10:10:05.000Z","updated_at":"2024-01-28T17:01:56.956Z","dependencies_parsed_at":"2022-08-25T07:22:26.520Z","dependency_job_id":null,"html_url":"https://github.com/dancecoder/json22-axios","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dancecoder/json22-axios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fjson22-axios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fjson22-axios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fjson22-axios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fjson22-axios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dancecoder","download_url":"https://codeload.github.com/dancecoder/json22-axios/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fjson22-axios/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018558,"owners_count":26086405,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["axios","axios-middleware","axios-plugin","json22","serialization-format"],"created_at":"2025-10-14T09:59:14.525Z","updated_at":"2025-10-14T09:59:19.117Z","avatar_url":"https://github.com/dancecoder.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON22-Axios\nAxios interceptor providing support to [JSON22](https://github.com/dancecoder/json22#readme) data format in your applications.\n\n## Features\n* Ready to use [Axios](https://axios-http.com/) interceptor\n* Parse [JSON22](https://github.com/dancecoder/json22#readme) body content\n* Serialize data to JSON22\n* Support for global interceptor as well as request level transformation\n* Both CJS/ESM modules support\n\n## Installation\n```shell\nnpm install json22-axios\n```\n\nAdd interceptor at your client setup\n```javascript\nimport axios from 'axios';\nimport { Json22RequestInterceptor } from 'json22-axios';\n\naxios.interceptors.request.use(Json22RequestInterceptor());\n```\n\nFor old-fashioned javascript\n\n```javascript\nconst axios = require('axios');\nconst { Json22RequestInterceptor } = require('json22-axios');\n\naxios.interceptors.request.use(Json22RequestInterceptor());\n```\n\n## Options\n\nBoth stringify and parse methods of JSON22 accepts options. You may be interested to define such options at global level as well as with isolated client instance.\n\n`Json22RequestInterceptor` accepts the next options structure\n\n```typescript\ninterface Json22AxiosOptions {\n    json22ParseOptions?: Json22ParseOptions;\n    json22StringifyOptions?: Json22StringifyOptions;\n}\n```\nSee also `Json22ParseOptions` and `Json22StringifyOptions` at [JSON22 API description](https://github.com/dancecoder/json22#api)\n\n### Define global level options\n```javascript\nimport axios from 'axios';\nimport { Json22RequestInterceptor } from 'json22-axios';\nimport { TypedModel } from './models/typed-model.js';\n\naxios.interceptors.request.use(Json22RequestInterceptor({\n    json22ParseOptions: { context: { TypedModel } },\n}));\n```\n\n### Define isolated client options\n```javascript\nimport axios from 'axios';\nimport { Json22RequestInterceptor } from 'json22-axios';\nimport { TypedModel } from './models/typed-model.js';\n\nconst client = axios.create();\nclient.interceptors.request.use(Json22RequestInterceptor({\n    json22ParseOptions: { context: { TypedModel } },\n}));\n```\n\n## Request level data transformation\nIn same rare cases you might be interested to set up data transformation for a specific query.\nThis case you shall not use the interceptor. Instead, you'll have to use data transformers functions. \nData transformers do not accept options, so you'll need to define it on query configuration at `json22Options`.\n```javascript\nimport axios from 'axios';\nimport { transformJson22StringToData, transformDataToJson22String } from 'json22-axios';\nimport { TypedModel } from './models/typed-model.js';\n\nexport async function postData(data) {\n    const resp = await axios.request({\n        method: 'POST',\n        baseURL: 'https://example.com',\n        url: '/api/data',\n        transformResponse: transformJson22StringToData,\n        transformRequest: transformDataToJson22String,\n        json22Options: { json22ParseOptions: { context: { TypedModel } } },\n        data\n    });\n    return resp.data;\n}   \n```\n__Note: `json22Options` configuration field is not defined by axios.__ \nThat is the reason we do not recommend to use json22 data transformers directly.\nPlease, use interceptor instead. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdancecoder%2Fjson22-axios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdancecoder%2Fjson22-axios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdancecoder%2Fjson22-axios/lists"}