{"id":31943603,"url":"https://github.com/dancecoder/superagent-json22","last_synced_at":"2025-10-14T09:59:20.473Z","repository":{"id":57374642,"uuid":"461082298","full_name":"dancecoder/superagent-json22","owner":"dancecoder","description":"Superagent plugin to work with JSON22 serialized data","archived":false,"fork":false,"pushed_at":"2022-02-19T17:33:24.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T12:00:06.572Z","etag":null,"topics":["json22","serialization","serialization-format","superagent","superagent-plugin"],"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-19T04:08:38.000Z","updated_at":"2022-02-19T17:37:53.000Z","dependencies_parsed_at":"2022-08-27T11:03:12.961Z","dependency_job_id":null,"html_url":"https://github.com/dancecoder/superagent-json22","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dancecoder/superagent-json22","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fsuperagent-json22","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fsuperagent-json22/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fsuperagent-json22/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fsuperagent-json22/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dancecoder","download_url":"https://codeload.github.com/dancecoder/superagent-json22/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dancecoder%2Fsuperagent-json22/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":["json22","serialization","serialization-format","superagent","superagent-plugin"],"created_at":"2025-10-14T09:59:13.750Z","updated_at":"2025-10-14T09:59:20.468Z","avatar_url":"https://github.com/dancecoder.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SuperAgent JSON22 Plugin\nSuperAgent plugin providing support to [JSON22](https://github.com/dancecoder/json22#readme) data format in your applications.\n\n## Features\n* Ready to use [SuperAgent](https://visionmedia.github.io/superagent/) plugin\n* Parse [JSON22](https://github.com/dancecoder/json22#readme) body content\n* Serialize data to JSON22\n* Can be used with [SuperTest](https://github.com/visionmedia/supertest#readme)\n* Both CJS/ESM modules support\n\n## Installation\n```shell\nnpm install superagent-json22\n```\n\nAdd plugin to a request\n```javascript\nimport superagent from 'superagent';\nimport { json22Plugin } from 'superagent-json22';\n\nasync function sendData() {\n    try {\n        return await superagent\n            .post('https://example.com/api/data')\n            .use(json22Plugin())\n            .send(data);\n    } catch (e) {\n        console.error(e);\n    }\n}\n```\n\nOld-fashioned javascript imports\n```javascript\nconst superagent = require('superagent');\nconst { json22Plugin } = require('superagent-json22');\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 Json22SuperagentPluginOptions {\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 options on each request\n```javascript\nimport superagent from 'superagent';\nimport { json22Plugin } from 'superagent-json22';\nimport { TypedModel } from './models/typed-model.js';\n\nasync function sendData() {\n    try {\n        return await superagent\n            .post('https://example.com/api/data')\n            .use(json22Plugin({\n                json22ParseOptions: { context: { TypedModel } },\n            }))\n            .send(data);\n    } catch (e) {\n        console.error(e);\n    }\n}\n```\n\n### Define an agent instance plugin options\n```javascript\nimport superagent from 'superagent';\nimport { json22Plugin } from 'superagent-json22';\nimport { TypedModel } from './models/typed-model.js';\n\nconst agent = superagent.agent().use(json22Plugin({\n    json22ParseOptions: { context: { TypedModel } },\n}));\n\nasync function sendData() {\n    try {\n        return await agent.post('https://example.com/api/data').send(data);\n    } catch (e) {\n        console.error(e);\n    }\n}\n```\n\n## Using with SuperTest\nSuperTest uses SuperAgent under the hood. SuperAgent isn't well isolated by SuperTest,\nso you can easily use any SuperAgent plugin including superagent-json22. Here is the example.\n```javascript\nimport supertest from 'supertest';\nimport { appFactory } from '../lib/app/appFatory.js';\nimport { TypedModel } from '../lib/models/typed-model.js';\n\nsuite('Response tests', () =\u003e {\n\n    test('supertest with plugin', (done) =\u003e {\n        const app = appFactory();\n        supertest(app)\n            .post('/')\n            .use(json22Plugin({ json22ParseOptions: { context: { TypedModel } }}))\n            .send(data)\n            .expect(200)\n            .then(resp =\u003e done())\n            .catch(done);\n    });\n\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdancecoder%2Fsuperagent-json22","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdancecoder%2Fsuperagent-json22","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdancecoder%2Fsuperagent-json22/lists"}