我无法通过NSJSONSerialization序列化负整数。
目标C:
if ($_POST) {
$first_number = $_POST['first_number'];
$second_number = $_POST['second_number'];
$cal = $_POST['cal'];
switch ('$cal') {
case "Addition":
$result = $first_number + $second_number;
break;
case "Subtraction":
$result = $first_number - $second_number;
break;
case "Multiplication":
$result = $first_number * $second_number;
break;
case "Division":
$result = $first_number / $second_number;
break;
case "Modulation":
$result = $first_number % $second_number;
break;
}
return $result;
}
echo "$cal <br /> <br /> 1st Number: $first_number <br /> 2nd Number: $second_number <br /><br />";
echo "Answer is:" . $result;
日志
NSMutableDictionary *sendData = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@480, @"width",
@800, @"height"
@-10, @"value1",
@10, @"value2", nil];
NSError *error = nil;
NSData *dataJSon = [NSJSONSerialization dataWithJSONObject:sendData options:0 error:&error];
NSLog(@"sendData\n %@ \n\n", [sendData description]);
如何序列化负整数?
答案 0 :(得分:2)
你纠正了,一切都很好。这只是字典 - 描述有误导性。
{{1}}