任何美化嵌套NSDictionary结果的工具

时间:2016-10-19 08:51:43

标签: ios objective-c swift nsdictionary

是否有任何工具(包括在线服务和macOs应用程序)来美化嵌套的NSDictionary结果?

   { 
        id = 1;
        testName = my name;
        createDate = 20021023;
        likeNumber = 0;
        statusList = ({
                appleId = 1;
                orangeName = 81;
                itsStatus = YES;
        });
        text = test;
        type = Text;
   },

我的意思是轻松地折叠(关闭和打开)树节点。

目前,在JSON Media media = new Media("http://icecast.unitedradio.it/Radio105.mp3"); MediaPlayer mediaPlayer = new MediaPlayer(media); MediaView mediaView = new MediaView(mediaPlayer); mediaView.setFitHeight(500); mediaView.setFitWidth(500); mediaPlayer.setVolume(new Double(1)); root.getChildren().add(mediaView); Button playButton = new Button(); playButton.setOnMouseClicked(new EventHandler<javafx.scene.input.MouseEvent>() { @Override public void handle(javafx.scene.input.MouseEvent event) { mediaPlayer.play(); } }); root.getChildren().add(playButton); primaryStage.setScene(scene); primaryStage.show(); <tbody> <?php $day = date('Y-m-d',strtotime('first day of this month')); for($i= 1; $i < date('t') + 1; $i++){ ?> <tr> <td><a href='#modal-dialog' class='btn btn-xs btn-success' data-toggle='modal'><span class='fa fa-pencil'></span>i=<?php echo $i; ?></td> <td><?php echo date('M-d',strtotime($day)); ?></td> <td><?php echo date('l',strtotime($day)); ?></td> <?php for($j =1;$j<=8;$j++){ echo "<td></td>".PHP_EOL; } ?> </tr> <?php $day = date('Y-m-d', strtotime('+1 day', strtotime($date))); } ?> </tbody> 时,有很多用于此目的的在线工具。

1 个答案:

答案 0 :(得分:0)

正如Fonix所提到的,将NSDictionary转换为JSON然后使用JSON工具实现此目的的最佳方法是:

+(NSString *)dictionaryToJson:(NSDictionary *)dictionary {
    NSError *error;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary
                                                       options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
                                                         error:&error];

    NSString *jsonString;
    if (! jsonData) {
        NSLog(@"Got an error: %@", error);
        jsonString = [error localizedDescription];
    } else {
        jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    }
    return jsonString;
}