{"id":6300,"library":"wtforms-json","title":"WTForms-JSON","description":"WTForms-JSON extends WTForms to provide convenient serialization and deserialization of form data to and from JSON, particularly useful for RESTful APIs. It allows forms to be populated directly from JSON payloads and validates them as usual. The latest version is 0.3.5, released in 2017. The project appears to be unmaintained.","status":"abandoned","version":"0.3.5","language":"en","source_language":"en","source_url":"https://github.com/kvesteri/wtforms-json","tags":["wtforms","json","rest","api","form-validation"],"install":[{"cmd":"pip install wtforms-json","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for form definition and validation.","package":"WTForms"}],"imports":[{"note":"Call this once to enable JSON handling for WTForms.","symbol":"init_app","correct":"from wtforms_json import init_app"}],"quickstart":{"code":"from wtforms import Form, StringField, IntegerField\nfrom wtforms.validators import DataRequired, NumberRange\nfrom wtforms_json import init_app\n\n# Initialize wtforms-json to extend WTForms functionality\ninit_app()\n\nclass UserProfileForm(Form):\n    name = StringField('Name', validators=[DataRequired()])\n    age = IntegerField('Age', validators=[NumberRange(min=0, max=120)])\n\n# Example JSON data (e.g., from a request body)\nvalid_json_data = {'name': 'Jane Doe', 'age': 25}\ninvalid_json_data = {'name': '', 'age': 150} # Name missing, age out of range\n\nprint(\"--- Processing valid data ---\")\nform_valid = UserProfileForm()\nform_valid.from_json(valid_json_data) # Populate form from JSON\n\nif form_valid.validate():\n    print(f\"Form is valid. Data: {form_valid.data}\")\nelse:\n    print(f\"Form errors: {form_valid.errors}\")\n\nprint(\"\\n--- Processing invalid data ---\")\nform_invalid = UserProfileForm()\nform_invalid.from_json(invalid_json_data)\n\nif form_invalid.validate():\n    print(f\"Form is valid. Data: {form_invalid.data}\")\nelse:\n    print(f\"Form errors: {form_invalid.errors}\")","lang":"python","description":"Demonstrates initializing wtforms-json and populating a form with JSON data, followed by validation. It shows handling both valid and invalid JSON inputs."},"warnings":[{"fix":"For new projects, consider modern alternatives or manually handle JSON serialization/deserialization. If migrating, thoroughly test with your specific WTForms and Python versions.","message":"WTForms-JSON has not been updated since 2017 and was last tested with WTForms 2.1. It is highly likely to have compatibility issues with modern WTForms 3.x+ and newer Python versions (3.8+).","severity":"breaking","affected_versions":"<=0.3.5"},{"fix":"Evaluate actively maintained alternatives for JSON handling with WTForms or implement custom solutions.","message":"The project is unmaintained. No new features, bug fixes, or security patches are expected. Relying on this library for new development is not recommended.","severity":"gotcha","affected_versions":"<=0.3.5"},{"fix":"Ensure `init_app()` is called early in your application's lifecycle, typically during setup or configuration.","message":"To enable JSON processing for all WTForms forms, `wtforms_json.init_app()` must be called once at the start of your application. Failing to do so will mean forms do not gain the `.from_json()` method.","severity":"gotcha","affected_versions":"<=0.3.5"},{"fix":"Be prepared to implement custom error formatting or validation logic around WTForms-JSON if specific error structures are required for your API.","message":"Error messages and validation behavior for JSON input might be less configurable or user-friendly compared to contemporary libraries or custom implementations.","severity":"gotcha","affected_versions":"<=0.3.5"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}