{"id":18368777,"url":"https://github.com/greena13/jason-form","last_synced_at":"2025-04-06T17:31:52.604Z","repository":{"id":57279437,"uuid":"47455437","full_name":"greena13/jason-form","owner":"greena13","description":"Converts JSON objects to array of Rails-friendly form-data key-value tuples","archived":false,"fork":false,"pushed_at":"2018-02-14T08:22:23.000Z","size":47,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T05:01:33.086Z","etag":null,"topics":["json","rails"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/greena13.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":"2015-12-05T12:43:00.000Z","updated_at":"2024-01-09T10:29:13.000Z","dependencies_parsed_at":"2022-08-30T02:50:44.431Z","dependency_job_id":null,"html_url":"https://github.com/greena13/jason-form","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greena13%2Fjason-form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greena13%2Fjason-form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greena13%2Fjason-form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greena13%2Fjason-form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greena13","download_url":"https://codeload.github.com/greena13/jason-form/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246758370,"owners_count":20828919,"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":["json","rails"],"created_at":"2024-11-05T23:27:25.116Z","updated_at":"2025-04-06T17:31:52.313Z","avatar_url":"https://github.com/greena13.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jason-form\n\n[![npm](https://img.shields.io/npm/dm/jason-form.svg)]()\n[![Build Status](https://travis-ci.org/greena13/jason-form.svg)](https://travis-ci.org/greena13/jason-form)\n[![GitHub license](https://img.shields.io/github/license/greena13/jason-form.svg)](https://github.com/greena13/jason-form/blob/master/LICENSE)\n\n\nUtility for converting arbitrarily deep JavaScript objects to FromData, using Rails conventions for nested arrays and objects.\n\nIf you use Rails views to generate and submit forms already, you do not need this library.\n\nIf you use some other method for generating your front end data, or have it as a JavaScript of JSON object, then this library can be considered the glue code needed to plug in to a Rails backend.\n\n## Usage\n\n```javascript\nimport jasonForm from 'jason-form';\n\nconst input = {\n string: 'string',\n array: [1,2],\n object: {\n  foo: 'foo',\n  bar: 'bar'\n  }\n};\n\nconst body = jasonForm.formData(input) // [['string', 'string'], ['array[]', 1], ['array[]', 2], ['object[foo]', 'foo'] ['object[bar]', 'bar']]\n\nfetch('http://my.rails.server', {\n  method: 'POST',\n  credentials: 'include',\n  body,\n  headers: {\n    'Content-Type': 'multipart/form-data'\n  }\n})\n```\n\n### Why not just submit the JavaScript object as a JSON request?\n\nIn most cases, this will work just fine and should indeed be the preferred approach. The issue is when you need to transmit data that is not supported by the JSON format (such as file upload data), or the backend that you need to send data to only accepts form data. Then this library becomes helpful.\n\n### What if my JavaScript object isn't already in a rails-friendly format (_attributes suffixes, snake_cased keys, etc)?\n\nRun it through [rails_request](https://github.com/greena13/rails-request) first.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreena13%2Fjason-form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreena13%2Fjason-form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreena13%2Fjason-form/lists"}