lib/jaspion/kilza/language/objc/m.erb in jaspion-kilza-1.0.8 vs lib/jaspion/kilza/language/objc/m.erb in jaspion-kilza-1.0.9

- old
+ new

@@ -36,10 +36,15 @@ } - (instancetype)initWithString:(NSString *)json { self = [super init]; +<% if @properties.length == 1 %> + if (![[json stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] hasPrefix:@"{"]) + json = [NSString stringWithFormat:@"{ \"%@\" : %@ }", k<%= @name %><%= @properties.first.name.capitalize %>, json]; + +<% end %> NSError *jsonError = nil; NSData *objectData = [json dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:objectData options:NSJSONReadingMutableContainers error:&jsonError];