Command-line tool for converting PLIST to JSON?

后端 未结 7 1595
粉色の甜心
粉色の甜心 2020-12-12 10:47

Is there a command line tool available for converting .plist files to JSON?

If not, what would be the approach for creating one using Objective-C or C on a Mac? For

相关标签:
7条回答
  • 2020-12-12 11:15

    The code is fairly simple to do this:

    NSArray* array = [[NSArray arrayWithContentsOfFile:[@"~/input.plist" stringByExpandingTildeInPath]]retain];
    SBJsonWriter* writer = [[SBJsonWriter alloc] init];
    NSString* s = [[writer stringWithObject:array] retain];
    [s writeToFile:[@"~/output.json" stringByExpandingTildeInPath] atomically:YES];
    [array release];
    

    I never got around to making it accept arguments as I only needed to do 3 files.

    0 讨论(0)
提交回复
热议问题