use*_*485 5 php apache-flex flash json rtmp
{
name: 'com.riotgames.platform.summoner.PublicSummoner',
keys: [ 'internalName', 'dataVersion', 'acctId', 'name', 'profileIconId', 'revisionDate', 'revisionId', 'summonerLevel', 'summonerId', 'futureData' ],
object: {
internalName: 'mrquackers',
dataVersion: 0,
acctId: { value: 34117327 },
name: 'MrQuackers',
profileIconId: 502,
revisionDate: Tue, 30 Oct 2012 19:38:32 GMT,
revisionId: { value: 0 },
summonerLevel: { value: 30 },
summonerId: { value: 20933307 },
futureData: null
},
encoding: 0
}
Run Code Online (Sandbox Code Playgroud)
(编辑器添加的换行符和缩进;不是响应的一部分)
这是来自RTMP数据包的响应,我不确定如何解析它.是否有一个PHP库或我可以将其转换为像json一样容易解析的东西?
如果您使用 Flash/AS3 接收此数据包,则可以使用as3corelib JSONDecoder类。
以下是使用您提供的 JSON 示例的示例:
import com.adobe.serialization.json.JSON;
var raw:String = "{ name: 'com.riotgames.platform.summoner.PublicSummoner', keys: [ 'internalName', 'dataVersion', 'acctId', 'name', 'profileIconId', 'revisionDate', 'revisionId', 'summonerLevel', 'summonerId', 'futureData' ], object: { internalName: 'mrquackers', dataVersion: 0, acctId: { value: 34117327 }, name: 'MrQuackers', profileIconId: 502, revisionDate: Tue, 30 Oct 2012 19:38:32 GMT, revisionId: { value: 0 }, summonerLevel: { value: 30 }, summonerId: { value: 20933307 }, futureData: null }, encoding: 0 }";
// 1. Add quotes to all keys. 2. Wrap string around date object. 3. Replace single quotes with double quotes.
raw = raw.replace(/([\w]+): /g, "'$1': ").replace(/\w+, \d* \w+ \d* \d*:\d*:\d* \w+/g, "'$&'").replace(/'/g, "\"");
var json:Object = JSON.decode(raw, false);
var date:Date = new Date(json.object.revisionDate);
trace(json.name); // "com.riotgames.platform.summoner.PublicSummoner"
trace(date.month); // 9
Run Code Online (Sandbox Code Playgroud)