如何在swift4中的数组内建立JSON对象?如何在swift4中获取此JSON的响应?我正在打印位置,但位置为public class rotateSurface : MonoBehaviour {
bool face;
Quaternion originalRotation;
Collider controller;
// Use this for initialization
void Start () {
face = false;
}
// Update is called once per frame
void Update () {
if(face){
var controllerPos = controller.transform.position;
Debug.Log(controllerPos);
transform.LookAt(controllerPos);
transform.rotation *= originalRotation;
}
}
void OnTriggerEnter (Collider other){ //Triggers when other collider enters the collision space from own.
if((other.gameObject.name.Contains("index"))||((other.gameObject.name.Contains("Hand"))&&other.gameObject.name.Contains("Right"))){ //If the object that collides is the hand or the index finger:
Debug.Log("original rotation: " + transform.rotation);
face = true;
originalRotation = transform.rotation;
controller = other;
}
}
void OnTriggerExit(Collider other){
face = false;
}
}
。
这是我的JSON数据:
nil
答案 0 :(得分:2)
/*
* C Program which Converts an Integer to String & vice-versa
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
void tostring(char [], int);
int main()
{
char str[10];
int num, result;
printf("Enter a number: ");
scanf("%d", &num);
tostring(str, num);
printf("Number converted to string: %s\n", str);
return 0;
}
void tostring(char str[], int num)
{
int i, rem, len = 0, n;
if(num<0)
{
n=(-1)*(num);
}
else
{
n=num;
}
while (n != 0)
{
len++;
n /= 10;
}
for (i = 0; i < len; i++)
{
rem = num % 10;
num = num / 10;
str[len - (i + 1)] = rem + '0';
}
str[len] = '\0';
}
不存在,因此不是数组。位置在地址数组内。
尝试
json["location"]
注意
if let addressArray = json["address"] as? [[String: Any]] {
let address = addressArray.first
let location = address?["location'] as? String
print(location)
}
我添加了一个字符串