jaspion-kilza 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e7abc9dfe396f9eef474cf11b374b791d3750b1
4
- data.tar.gz: 60814db03aaf45197f5f36c70bba4b54882883fc
3
+ metadata.gz: eb863f539668936bbfcc38b09be56efe00fc9c58
4
+ data.tar.gz: 4cdea48ae8354c0b4d1dcb48238a0c21848c51c7
5
5
  SHA512:
6
- metadata.gz: 0da939967226bd29ee3b9ab272f596ee07faf252a8c6b1dd1cd199b34ddb4d966452b7bc4817a65599aaef40f6e75a6dd8eb2917db9edefbe463e717f3089397
7
- data.tar.gz: f9e4469139c16cea2fc524709f36c304b2d4534cb56e982fe4ab7a52961c0e0d9d645905bd93514049b81bc253e34af985d2c24ed0da10955b0702acd27be105
6
+ metadata.gz: 54acf2e90227058d1a6dc5c31d683bf42834f5a02ffe77bc695de8939d840be17b0426da5d476db5b86bdc73d9963f89a062af668a98583d2076ad48ca7f013b
7
+ data.tar.gz: 2895c608667a76fff1a22820532aad55faa9265154e953d68c9bdaa2dac36c478c6f7a2adc74eaecbcdb32bdc7e5b7b25522660fe3a64e47fa56ce7f441a0632
@@ -28,6 +28,7 @@ module Jaspion
28
28
  #
29
29
  # @return [String] cleaned string
30
30
  def self.clean(str)
31
+ return if str.nil?
31
32
  str = '_' + str if str[0].number?
32
33
  str.gsub(/[^a-zA-Z0-9]/, '_')
33
34
  end
@@ -38,6 +39,7 @@ module Jaspion
38
39
  #
39
40
  # @return [String] cleaned string
40
41
  def self.normalize(str)
42
+ return if str.nil?
41
43
  Jaspion::Kilza.clean(str).downcase
42
44
  end
43
45
  end
@@ -26,6 +26,12 @@ module Jaspion
26
26
  # Hash table with all language types mapped to target language
27
27
  attr_accessor :types
28
28
 
29
+ # Initializes the language
30
+ # If json_string is not a Hash {}, it will surroud the json with
31
+ # { "base_name"} = json_string
32
+ #
33
+ # @param json_string [String] JSON String
34
+ #
29
35
  def initialize(json_string)
30
36
  @json_string = json_string
31
37
  @classes = []
@@ -70,8 +76,11 @@ module Jaspion
70
76
  #
71
77
  # @return [Kilza::Property] new property
72
78
  def property(name, type, array, key)
79
+ original_name = name
73
80
  name = @reserved_delimiter + name unless @reserved_words.index(name).nil?
74
- Property.new(name, type, array, key)
81
+ prop = Property.new(name , type, array, key)
82
+ prop.original_name = original_name
83
+ prop
75
84
  end
76
85
 
77
86
  # Searches for a Kilza::Class inside @classes
@@ -44,6 +44,10 @@ public class <%= @name %> implements Serializable
44
44
  }
45
45
 
46
46
  protected void parseString(String jsonString) throws JSONException {
47
+ <% if @properties.length == 1 %>
48
+ if (!jsonString.trim().startsWith("{"))
49
+ jsonString = "{\"" + FIELD_<%= @properties.first.name.upcase %> + "\" : " + jsonString + "}";
50
+ <% end %>
47
51
  JSONObject jsonObject = new JSONObject(jsonString);
48
52
  parseObject(jsonObject);
49
53
  }
@@ -38,7 +38,12 @@ NSString * const k<%= @name %><%= @property.name.capitalize %> = @"<%= @property
38
38
  - (instancetype)initWithString:(NSString *)json
39
39
  {
40
40
  self = [super init];
41
+ <% if @properties.length == 1 %>
41
42
 
43
+ if (![[json stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] hasPrefix:@"{"])
44
+ json = [NSString stringWithFormat:@"{ \"%@\" : %@ }", k<%= @name %><%= @properties.first.name.capitalize %>, json];
45
+
46
+ <% end %>
42
47
  NSError *jsonError = nil;
43
48
  NSData *objectData = [json dataUsingEncoding:NSUTF8StringEncoding];
44
49
  NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:objectData
@@ -1,6 +1,6 @@
1
1
  # Tranforms a JSON string into Objects
2
2
  module Jaspion
3
3
  module Kilza
4
- VERSION = '1.0.8'
4
+ VERSION = '1.0.9'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jaspion-kilza
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiro Sugii