{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "classroom = {\n",
    "            'name' : ['ali', 'ahmad', 'akbar', 'leila', 'maryam', 'zahra'],\n",
    "            'score' : [12, 15, 18, 16, 14, 20],\n",
    "            'birthday' : ['1375', '1374', '1375', 'NONE' , '1376', '1373'],\n",
    "            'married' : ['yes', 'yes', 'NONE', 'no', 'NONE', 'no'],\n",
    "            'gender' : ['m', 'm', 'm', 'f', 'f', 'f']\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': ['ali', 'ahmad', 'akbar', 'leila', 'maryam', 'zahra'],\n",
       " 'score': [12, 15, 18, 16, 14, 20],\n",
       " 'birthday': ['1375', '1374', '1375', 'NONE', '1376', '1373'],\n",
       " 'married': ['yes', 'yes', 'NONE', 'no', 'NONE', 'no'],\n",
       " 'gender': ['m', 'm', 'm', 'f', 'f', 'f']}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "classroom"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "f = open(file = \"D:\\\\faradars\\\\files\\\\json_file.json\", mode='w')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "json.dump(classroom, f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "f.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(file = \"D:\\\\faradars\\\\files\\\\json_file.json\", mode='w') as f:\n",
    "    json.dump(classroom, f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(file = \"D:\\\\faradars\\\\files\\\\json_file.json\", mode='r') as f:\n",
    "    classroom1 = json.load(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'name': ['ali', 'ahmad', 'akbar', 'leila', 'maryam', 'zahra'],\n",
       " 'score': [12, 15, 18, 16, 14, 20],\n",
       " 'birthday': ['1375', '1374', '1375', 'NONE', '1376', '1373'],\n",
       " 'married': ['yes', 'yes', 'NONE', 'no', 'NONE', 'no'],\n",
       " 'gender': ['m', 'm', 'm', 'f', 'f', 'f']}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "classroom1"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
