Metadata-Version: 1.1
Name: json-model
Version: 1.0.1
Summary: Json-Model is simple library to create Json Models from Python Objects. Library supports field validation by Python Types and required fields.
Home-page: UNKNOWN
Author: Sławomir Kabik
Author-email: slawek@redsoftware.pl
License: Copyright (c) 2018, Sławomir Kabik
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of the {organization} nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Download-URL: https://github.com/slawek87/json-model
Description: # Json-Model
        
        Json-Model is simple library to create Json Models from Python Objects. Library supports field validation by Python Types and required fields.
        
        # Usage
        
        Usage is really simple. Json-Model on this moment supports 7 basics fields:
        - `Integer`
        - `String`
        - `Float`
        - `List`
        - `Timestamp`
        - `Datetime`
        - `ForeignField`
        
        Each field has attribute:
        - `required` - Boolean attribute in default is set to `False`.
        - `default` - set default value when field is empty.
        
        To start work with JsonModel, create Json-Model class with all fields what you need in Json object.
        
        ```python
        import datetime
        import time
        
        from json_model import fields
        from json_model import libs
        
        
        class Scholarship(libs.JsonModel):
            amount = fields.Float(required=True)
            currency = fields.String(default='USD')
            months = fields.List(required=True)
        
        
        class Student(libs.JsonModel):
            name = fields.String(required=True)
            surname = fields.String(required=True)
            age = fields.Integer()
            day_of_birth = fields.Datetime()
            scholarship = fields.ForeignField()
        
            created_at = fields.Timestamp()
        
        
        if __name__ == '__main__':
            scholarship = Scholarship()
            scholarship.amount = 500.00
            scholarship.months = [1, 2, 3, 4, 5, 8, 9, 10]
        
            student = Student()
            student.name = "Andrew"
            student.surname = "Gardner"
            student.age = 26
            student.day_of_birth = datetime.datetime.strptime('Jun 1 1999  1:33PM', '%b %d %Y %I:%M%p')
        
            student.scholarship = scholarship
        
            student.created_at = int(time.time())
        
            print(student.to_json())
        
            # Create objects by dictionary objects as parameter of JsonModel class.
            student = Student(**{
                'name': 'Andrew',
                'surname': 'Gardner',
                'age': 26,
                'day_of_birth': datetime.datetime.strptime('Jun 1 1999  1:33PM', '%b %d %Y %I:%M%p'),
                'scholarship': Scholarship(**{'amount': 500.00, 'months': [1, 2, 3, 4]}),
                'created_at': int(time.time())
                }
            )
        
            print(student.to_json())
        ```
        
        Congratulation You have just created your first JsonModel implementation.
Keywords: Python Json,Python serializers,Python Json Model
Platform: UNKNOWN
