小编Old*_*Fox的帖子

RestKit 0.20 - 动态嵌套对象映射

我正在使用Objective C项目,该项目使用RestKit框架来解析JSON响应.现在我需要一些关于以下情况的对象映射设置的帮助:JSON响应:

    {
   "data": {
       "SOME.API.Auth": {
           "maxVersion": 2,
           "minVersion": 1,
           "path": "auth.cgi"
       },
       "SOME.Station": {
           "maxVersion": 1,
           "minVersion": 1,
           "path": "Station/task.cgi"
       }
   },
   "success": true
}
Run Code Online (Sandbox Code Playgroud)

和以下对象:

@interface Response : NSObject
@property (strong, nonatomic) NSArray *data;
@property (assign, nonatomic) BOOL success;
@end


@interface SomeAPIInfo : NSObject
@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSString *path;
@property (strong, nonatomic) NSString *minVersion;
@property (strong, nonatomic) NSString *maxVersion;
@end
Run Code Online (Sandbox Code Playgroud)

这是我的映射设置:

RKObjectMapping *responseMapping = [RKObjectMapping mappingForClass:[Response class]];
[responseMapping addAttributeMappingsFromDictionary:@{@"success": @"success"}];

RKObjectMapping *dataObjectMapping …
Run Code Online (Sandbox Code Playgroud)

mapping json objective-c restkit

5
推荐指数
1
解决办法
1200
查看次数

如何从BATCH中的字符串中提取数字

我想提取路径字符串中的第一个数字.

一些例子

c:\dir\release1\temp  should extract: 1
c:\dir\release11\temp  should extract: 11
c:\dir\release1\temp\rel2  should extract: 1
c:\dir\release15a\temp  should extract: 15
Run Code Online (Sandbox Code Playgroud)

我当前的代码,循环文件夹名称,并测试文件夹名称是否为数字(我需要在这里进行一些更改):

setlocal enableextensions enabledelayedexpansion
set line=one\two\three\4\pet\0\sest\rel6\a
rem set line=%cd%
:processToken
for /f "tokens=1* delims=\" %%a in ("%line%") do (
echo Token: %%a
set line=%%b
rem need fix here: need to extract number from string
echo %%a|findstr /r /c:"^[0-9][0-9]*$" >nul
if errorlevel 1 (echo not a number) else (echo number)
)
if not "%line%" == "" goto :processToken
endlocal
Run Code Online (Sandbox Code Playgroud)

谢谢!

编辑:我想解析该路径字符串中的数字.好吧,我找到了只检查字符串的最后3个字符的解决方案.现在好了.

::test last …
Run Code Online (Sandbox Code Playgroud)

string parsing batch-file

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

batch-file ×1

json ×1

mapping ×1

objective-c ×1

parsing ×1

restkit ×1

string ×1