import gzip
import json


def get_reviews_data(inputdata, list_users):
	""" Extracts reviews info from json file: book_id, user_id, rating and review text
	
	Args:
		inputdata (:obj:`json`): json file of reviews per user
		list_users (:obj:`list`): list of users from rating matrix
	Returns:
		:obj:`reviews`: dict of reviews
	"""
	reviews = []
	with gzip.open(inputdata) as json_file:
		for lines in json_file:
			review = {}
			line = json.loads(lines)
			if line['user_id'] in list_users:
				review['book_id'] = line['book_id']
				review['user_id'] = line['user_id']
				review['rating'] = line['rating']
				review['review_text'] = line['review_text']
				reviews.append(review)
	return reviews