3breadt / dd-plist

A java library providing support for ASCII, XML and binary property lists.
Other
258 stars 94 forks source link

NSArray should implement List #61

Closed aelam closed 3 years ago

aelam commented 4 years ago

When I try to convert a plist to json, the structure goes to weird when It parse NSArray, I think it's the reason that it doens't implement List

aelam commented 4 years ago

just change the instance type of array in Class NSArray to private ArrayList<NSObject> array; can save a lot of energy

3breadt commented 4 years ago

When I try to convert a plist to json, the structure goes to weird when It parse NSArray, I think it's the reason that it doens't implement List

Have you tried converting the NSObjects to Java Objects before passing them to the JSON serializer? See https://3breadt.github.io/dd-plist/com/dd/plist/NSObject.html#toJavaObject--

aelam commented 4 years ago

I just did a general operation, convert a NSDictionary object which contains NSArray to json string, I didn't convert to Java objects, but i changes the internal class from Array to ArrayList, it can be processed greatly

BTW the json way just work for plain XML PropertyList and I need serializers for NSNumber and NSString

AND it doesn't work for NSData, i can understand it, im looking for a better to convert plist to objects like gson does.

I will appreciate if you have any ideas

3breadt commented 3 years ago

Please do not convert the NSObjects directly to JSON. The classes were not designed for that. Rather as mentioned, convert them first to POJOs which are most likely supported by any JSON serializer.