Skip to content

Commit

Permalink
Merge pull request sinnerschrader-mobile#21 from kimar/master
Browse files Browse the repository at this point in the history
Replaces dot, dash, comma in json-key by underscore for generating safe ...
  • Loading branch information
Sanggeon Park committed Jul 15, 2014
2 parents d9e8abe + 907a400 commit eff2f6e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ObjectiveCCodeGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
'''

import datetime, time, os
import datetime, time, os, re

class ObjectiveCCodeGenerator :

Expand Down Expand Up @@ -51,7 +51,7 @@ def getSourceDescriptionString(self, name) :
return mDescriptionString

def makeVarName(self,schemeObj) :
returnName = schemeObj.type_name
returnName = re.sub('[,.-]', '_', schemeObj.type_name)
if str(schemeObj.type_name) == "id" or str(schemeObj.type_name) == "description" :
titleName = schemeObj.type_name.upper()
titleName = titleName[:1] + schemeObj.type_name[1:]
Expand Down Expand Up @@ -701,6 +701,8 @@ def getNaturalTypeGetterFromDictionaryCode(self, schemeObj, className, varName,
dateObjSubType = schemeObj.getSubType()
if len(dateObjSubType) and dateObjSubType[0] == str("ms") :
resultString += firstIndent + className + varName + " = [" + self.projectPrefix + "APIParser dateWithMilliSecondsTimeIntervalFromResponseDictionary:" + dicName + " forKey:@\"" + keyName + "\" acceptNil:"
elif len(dateObjSubType) and dateObjSubType[0] == str("iso8601") :
resultString += firstIndent + className + varName + " = [" + self.projectPrefix + "APIParser dateFromResponseDictionary:" + dicName + " forKey:@\"" + keyName + "\" acceptNil:"
else :
resultString += firstIndent + className + varName + " = [" + self.projectPrefix + "APIParser dateWithTimeIntervalFromResponseDictionary:" + dicName + " forKey:@\"" + keyName + "\" acceptNil:"
elif schemeBaseType == "data" :
Expand Down
12 changes: 10 additions & 2 deletions doc/MetaJSONProtocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,19 @@ You can also use just one of those ("minValue" or "maxValue").
"description" : string
"minValue" : UTC time interval since 1970
"maxValue" : UTC time interval since 1970
}
},
{
"name" : "myISO8601Date",
"base-type" : "date",
"subType" : "iso8601",
"description" : string
"minValue" : UTC time interval since 1970
"maxValue" : UTC time interval since 1970
},
```

* The value of myDate should be always UTC time interval since 1970.
* "subType" is optional, to specify wheather it's millisecond based timestamp or second based timestamp.
* "subType" is optional, to specify wheather it's millisecond based timestamp, a second based timestamp or an ISO 8601 timestamp.
* If "subType" is specified as "ms", "minValue" and "maxValue" should be used like "1382455623.098"
* "minValue" and "maxValue" are optional, to validate this type.
* "maxValue" should be always same or later than "minValue".
Expand Down

0 comments on commit eff2f6e

Please sign in to comment.