expect pass a series that each row is string formated Json data with the same structure
335643
def series2df(Series, layer=2, split_sign = '_'):
    """"""
    try:
        Series.columns
        Series = Series.iloc[:,0]
    except:
        pass
    
    def _helper(x, layer=2):
        try:
            return flatten_dict(ast.literal_eval(x), layers=layer, split_sign=split_sign)
        except:
            try:
                return flatten_dict(x, layers=layer, split_sign=split_sign)
            except:
                return x
    
    df=pd.DataFrame(Series.apply(_helper).tolist())
    
    return df
1187770
def format_data(data, json = false)
      if json
        JSON.generate(data)
      else
        data.map do |category, cat_data|
          # Capitalize each word in the category symbol.
          # e.g. :liked_tracks becomes 'Liked Tracks'
          title = category.to_s.split('_').map(&:capitalize).join(' ')

          output = if cat_data.empty?
                     "  ** No Data **\n"
                   else
                     case category
                     when /liked_tracks/
                       formatter.tracks(cat_data)
                     when /liked_artists|liked_stations/
                       formatter.sort_list(cat_data)
                     when :liked_albums
                       formatter.albums(cat_data)
                     when /following|followers/
                       formatter.followx(cat_data)
                     end
                   end

          "#{title}:\n#{output}"
        end.join
      end
    end
1067007
def prepare(data):
    """"""
    ref = data.get("ref")
    obj = data.get("object")
    sha = obj.get("sha")
    return {"ref": ref, "head": {"sha": sha}}
351553
def jsonify(py_data, default=None, indent=4, sort_keys=True):
    
    return json.dumps(py_data, default=py2json, indent=indent, sort_keys=sort_keys)
354437
def shell2json(s):
    """"""
    replace = {
        r'BinData\(.+?\)': '1',
        r'(new )?Date\(.+?\)': '1',
        r'Timestamp\(.+?\)': '1',
        r'ObjectId\(.+?\)': '1',
        r'DBRef\(.+?\)': '1',
        r'undefined': '1',
        r'MinKey': '1',
        r'MaxKey': '1',
        r'NumberLong\(.+?\)': '1',
        r'/.+?/\w*': '1'
    }

    for key, value in replace.items():
        s = re.sub(key, value, s)

    return s
1012400
def to_json(df, x, y):
        """"""
        values = []
        for i, row in df.iterrows():
            values.append({
                "x": row[x],
                "y": row[y]
                })

        if df.empty:
            return {"result": [{"x": 0, "y": 0}], "date": False}

        return {"result": values, "date": False}
801584
function expectJSON(fn, res) {
  bluebird.try(fn).then(function (result) {
    res.json(result);
  }).catch(handleError(res));
}
77838
def json_loads(data):
    """"""
    if data is None:
        return ""

    if data == "-":
        return json.load(sys.stdin)
    elif os.path.exists(data):
        with open(data, 'r') as handle:
            return json.load(handle)
    else:
        return json.loads(data)
847444
def stringify(data):
    """"""
    if isinstance(data, dict):
        for key, value in data.items():
            data[key] = stringify(value)
    elif isinstance(data, list):
        return [stringify(item) for item in data]
    else:
        return smart_text(data)

    return data
658604
def prepare(data):
    """"""
    result = {}
    result["mode"] = data.get("mode")
    result["path"] = data.get("path")
    result["type"] = data.get("type")
    result["sha"] = data.get("sha")
    return result
993324
def formatfundbjson(fundbjson):
        """"""
        result = {}
        for row in fundbjson["rows"]:
            cell = row["cell"]
            fundb_id = cell["fundb_id"]
            result[fundb_id] = cell
        return result
1154939
def _dump_json(self, data, new_line=False):
        

        # We do not want any spaces between keys and values in JSON
        json_data = json.dumps(data, separators=(',', ':'))

        if new_line:
            json_data = "%s\n" % json_data

        # Generate sha256sum of the JSON data, may be handy
        sha = hashlib.sha256(json_data.encode('utf-8')).hexdigest()

        return json_data, sha
217322
def flatten_json(data, prefix = None):
    '''
    
    '''
    # iterate all items
    for item in data:
        # split the object
        flat, key, subs = split_obj(item, prefix)

        # just return fully flat objects
        if key is None:
            yield flat
            continue

        # otherwise recursively flatten the subobjects
        for sub in flatten_json(subs, key):
            sub.update(flat)
            yield sub
459499
def json_format(out, graph):
    """"""
    steps = {}
    for step, deps in each_step(graph):
        steps[step.name] = {}
        steps[step.name]["deps"] = [dep.name for dep in deps]

    json.dump({"steps": steps}, out, indent=4)
    out.write("\n")
27554
async def apply_json(self, data):
        
        if not isinstance(data, list):
            data = [data]
        result = []
        for entry in data:
            name = entry.pop('name')
            if await self.has(name):
                sni = await self.update(name, **entry)
            else:
                sni = await self.create(name=name, **entry)
            result.append(sni.data)
        return result
911289
def handle_string(self, strreq):
        '''
        
        '''

        #convert to jsonrpc-dict
        req = None
        try:
            req = json.loads(strreq)
        except:
            logging.debug('JSONRPC: Format Exception:')
            logging.debug('-----------------\n' + traceback.format_exc())
            return json.dumps(SLOJSONRPCError(-32700).to_json())

        #handle single request
        if isinstance(req, dict):
            return json.dumps(self.handle_request(req))
        #handle multiple requests
        elif isinstance(req, list):
            for r in req:
                if not isinstance(r, dict):
                    logging.debug('JSONRPC: Fmt Error: Item ' +
                                  '"%s" in request is no dictionary.' % str(r))
                    return json.dumps(SLOJSONRPCError(-32700).to_json())
                try:
                    self._validate_format(r)
                    self._validate_params(r)
                except SLOJSONRPCError as e:
                    return json.dumps(e.to_json(r.get('id', None)))

            res = []
            for r in req:
                res.append(self.handle_request(r, validate=False))
            return json.dumps(res)
        #invalid request
        else:
            return json.dumps(SLOJSONRPCError(-32700).to_json())
988600
def loadJson(self, data):
        """"""
        if not isinstance(data, dict):
            data = json.loads(data)
        self.__dict__.update(data)
        self.inflate() # restore objects from str values
        #if self.ports:  self._gotPorts = True
        return self