为什么hms data payload可以自动将jsonObject转为map

Why hms data payload can automatically convert jsonObject to map

来自示例。

{
    "message": {
        "data": "{ 'score': '7', 'time': '16:42' }",
        "notification": {
            "title": "message title",
            "body": "message body"
        },
        "android": {
            "data": "{ 'androidData': '7', 'time': '16:42' }",
            "notification": {
                "click_action": {
                    "type": 1,
                    "action": "com.huawei.codelabpush.intent.action.test"
                }
            }
        },
        "token": [
            "pushtoken1"
        ]
    }
}

数据是一个jsonObject payload,为什么可以作为map对象获取。

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getIntentData(getIntent());
    }
 
    @Override
    public void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        getIntentData(intent);
    }

    private void getIntentData(Intent intent) {
        if (null != intent) {           
            // Obtain the value in data.
            Bundle bundle = intent.getExtras();
            if (bundle != null) {
                for (String key : bundle.keySet()) {  // <---- Get like a map object.
                    String content = bundle.getString(key);
                    Log.i(TAG, "receive data from push, key = " + key + ", content = " + content);
                }
            }
        } else {
            Log.i(TAG, "intent is null");
        }
    }
}

经团队确认,客户端 SDK 解析数据参数,然后将其添加到意图中。