{ "info": { "author": "S\u0142awomir Kabik", "author_email": "slawek@redsoftware.pl", "bugtrack_url": null, "classifiers": [], "description": "# Json-Model\n\nJson-Model is simple library to create Json Models from Python Objects. Library supports field validation by Python Types and required fields.\n\n# Usage\n\nUsage is really simple. Json-Model on this moment supports 7 basics fields:\n- `Integer`\n- `String`\n- `Float`\n- `List`\n- `Timestamp`\n- `Datetime`\n- `ForeignField`\n\nEach field has attribute:\n- `required` - Boolean attribute in default is set to `False`.\n- `default` - set default value when field is empty.\n\nTo start work with JsonModel, create Json-Model class with all fields what you need in Json object.\n\n```python\nimport datetime\nimport time\n\nfrom json_model import fields\nfrom json_model import libs\n\n\nclass Scholarship(libs.JsonModel):\n amount = fields.Float(required=True)\n currency = fields.String(default='USD')\n months = fields.List(required=True)\n\n\nclass Student(libs.JsonModel):\n name = fields.String(required=True)\n surname = fields.String(required=True)\n age = fields.Integer()\n day_of_birth = fields.Datetime()\n scholarship = fields.ForeignField()\n\n created_at = fields.Timestamp()\n\n\nif __name__ == '__main__':\n scholarship = Scholarship()\n scholarship.amount = 500.00\n scholarship.months = [1, 2, 3, 4, 5, 8, 9, 10]\n\n student = Student()\n student.name = \"Andrew\"\n student.surname = \"Gardner\"\n student.age = 26\n student.day_of_birth = datetime.datetime.strptime('Jun 1 1999 1:33PM', '%b %d %Y %I:%M%p')\n\n student.scholarship = scholarship\n\n student.created_at = int(time.time())\n\n print(student.to_json())\n\n # Create objects by dictionary objects as parameter of JsonModel class.\n student = Student(**{\n 'name': 'Andrew',\n 'surname': 'Gardner',\n 'age': 26,\n 'day_of_birth': datetime.datetime.strptime('Jun 1 1999 1:33PM', '%b %d %Y %I:%M%p'),\n 'scholarship': Scholarship(**{'amount': 500.00, 'months': [1, 2, 3, 4]}),\n 'created_at': int(time.time())\n }\n )\n\n print(student.to_json())\n```\n\nCongratulation You have just created your first JsonModel implementation.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/slawek87/json-model", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "Python Json", "license": "Copyright (c) 2018, S\u0142awomir Kabik\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n* Neither the name of the {organization} nor the names of its\n contributors may be used to endorse or promote products derived from\n this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n", "maintainer": "", "maintainer_email": "", "name": "json-model", "package_url": "https://pypi.org/project/json-model/", "platform": "", "project_url": "https://pypi.org/project/json-model/", "project_urls": { "Download": "https://github.com/slawek87/json-model" }, "release_url": "https://pypi.org/project/json-model/1.0.1/", "requires_dist": null, "requires_python": "", "summary": "Json-Model is simple library to create Json Models from Python Objects. Library supports field validation by Python Types and required fields.", "version": "1.0.1" }, "last_serial": 3458792, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "1692d23d00266699035bf298bb3cfaf8", "sha256": "52f2ae4ed06f81a423a92fd422e44ca41b42723b0ece91215982add9c28efbec" }, "downloads": -1, "filename": "json-model-1.0.1.tar.gz", "has_sig": false, "md5_digest": "1692d23d00266699035bf298bb3cfaf8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3576, "upload_time": "2018-01-03T11:29:07", "url": "https://files.pythonhosted.org/packages/01/06/74799af96912e148242ac02c0b7c9fe95733de635542b9aa43520af8045c/json-model-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1692d23d00266699035bf298bb3cfaf8", "sha256": "52f2ae4ed06f81a423a92fd422e44ca41b42723b0ece91215982add9c28efbec" }, "downloads": -1, "filename": "json-model-1.0.1.tar.gz", "has_sig": false, "md5_digest": "1692d23d00266699035bf298bb3cfaf8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3576, "upload_time": "2018-01-03T11:29:07", "url": "https://files.pythonhosted.org/packages/01/06/74799af96912e148242ac02c0b7c9fe95733de635542b9aa43520af8045c/json-model-1.0.1.tar.gz" } ] }