Write a function named "json_filter" that takes a JSON formatted string as a parameter in the format of an array of objects where each object has keys "mass", "density", "temperature", and "velocity" and each key maps to a floating point number. This function should return the input as a JSON string in the same format but with only the objects with velocity greater than 38.46

Respuesta :

Answer:

Check the explanation

Explanation:

kindly check the well written code below to get the solution to your question.

import json

def json_filter(input_string):

   jsonFormat = json.loads(input_string)

   result = []

   for obj in jsonFormat:

       if obj["temperature"] > 38.46:

           result.append(obj)

   return json.dumps(result)