Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
538 views
in Technique[技术] by (71.8m points)

swift4 - Unable to Extract Data from the Dictionary<String, Any> in swift

I have a Dictionary<String, Any> Data in the following format. I need to extract the values from it.I am unable to extract the values, initially it looked to me as JSON but it's of type Dictionary<String, Any>. Can anyone help me out.

 **{
        message =     {
            "pn_apns" =         {
                aps =             {
                    alert =                 {
                        body = "Andy - Picture added!";
                        roomId = 1611711512726;
                        title = "New chat on flag - New flag ";
                    };
                    sound = default;
                };
            };
            senderId = "XXXX@XXXXX";
            text = "Euclid%20Ave./Flag%20%26%20Chat/New%20flag%20/Original/1AF3956D-AEC4-485C-B8C2-3F97AEE05C58.png";
            type = P;
            uuid = "XXXXXXX-70CB-4301-DDDD-FFFFFFFF";
        };
        timetoken = 16117629931914202;
        uuid = "XXXX@XXXXX";
    }**
question from:https://stackoverflow.com/questions/65944473/unable-to-extract-data-from-the-dictionarystring-any-in-swift

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This isn't a JSON.

Look at https://www.json.org/json-en.html site.

To check the string, use https://jsonlint.com


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...