#NEWLINE# def ofp_msg_from_jsondict( dp , jsondict ) : #NEWLINE# #INDENT# '\n    This function instanticates an appropriate OpenFlow message class\n    from the given JSON style dictionary.\n    The objects created by following two code fragments are equivalent.\n\n    Code A::\n\n        jsonstr = \'{ "OFPSetConfig": { "flags": 0, "miss_send_len": 128 } }\'\n        jsondict = json.loads(jsonstr)\n        o = ofp_msg_from_jsondict(dp, jsondict)\n\n    Code B::\n\n        o = dp.ofproto_parser.OFPSetConfig(flags=0, miss_send_len=128)\n\n    This function takes the following arguments.\n\n    ======== =======================================\n    Argument Description\n    ======== =======================================\n    dp       An instance of ryu.controller.Datapath.\n    jsondict A JSON style dict.\n    ======== =======================================\n    ' #NEWLINE# parser = dp . ofproto_parser #NEWLINE# assert ( len ( jsondict ) == 1 ) #NEWLINE# for ( k , v ) in jsondict . items ( ) : #NEWLINE# #INDENT# cls = getattr ( parser , k ) #NEWLINE# assert issubclass ( cls , MsgBase ) #NEWLINE# return cls . from_jsondict ( v , datapath = dp )