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
279 views
in Technique[技术] by (71.8m points)

Swift - JSON Add the key names into an array

I want to take the JSON key names and add them into an array.

{
   "name": "Battleaxe, tactical",
   "price": 2650,
   "level": 5,
   "bulk": "1",
   "special": ["Analog"],
   "damage": "1d8 S",
   "source": "Incident at Absalom Station",
   "hands": 1,
   "critical": "Wound",
   "category": "Uncategorized",
   "proficiency": "Advanced Melee"
 }

With the JSON above I want to create and array in Swift:

let testArray: ["name", "price", "level"...]

I am still pretty new to playing with JSON in Swift and haven't found what I am looking for. Right now I am hard coding each array per object. I have a lot of different JSON files so being able to have something like this would help out alot.

question from:https://stackoverflow.com/questions/65850311/swift-json-add-the-key-names-into-an-array

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

1 Answer

0 votes
by (71.8m points)
Waitting for answers

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

...