本文整理汇总了C#中JSONObject.SetField方法的典型用法代码示例。如果您正苦于以下问题:C# JSONObject.SetField方法的具体用法?C# JSONObject.SetField怎么用?C# JSONObject.SetField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONObject
的用法示例。
在下文中一共展示了JSONObject.SetField方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetVec2
private void SetVec2(Vector2 value)
{
JSONObject vecJson = new JSONObject();
vecJson.SetField("x",value.x);
vecJson.SetField("y",value.y);
VariableManager.JsonRecord.SetField(ID,vecJson);
}
示例2: SetBoolList
private void SetBoolList(List<bool> boolList)
{
JSONObject listJson = new JSONObject();
for(int i=0;i<boolList.Count;i++)
{
listJson.SetField("item"+i,boolList[i]);
}
VariableManager.JsonRecord.SetField(ID,listJson);
}
示例3: GeneratePositionUpdatePacket
public JSONObject GeneratePositionUpdatePacket()
{
if (!_positionUpdatePacket)
{
_positionUpdatePacket = new JSONObject();
_positionUpdatePacket.SetField("pos", new JSONObject(JSONObject.Type.ARRAY));
}
_positionUpdatePacket.AddField("pos", delegate(JSONObject o)
{
o.Add(transform.position.x);
o.Add(transform.position.y);
});
return _positionUpdatePacket;
}
示例4: MergeRecur
/// <summary>
/// Merge object right into left recursively
/// </summary>
/// <param name="left">The left (base) object</param>
/// <param name="right">The right (new) object</param>
static void MergeRecur(JSONObject left, JSONObject right) {
if(left.type == JSONObject.Type.NULL)
left.Absorb(right);
else if(left.type == Type.OBJECT && right.type == Type.OBJECT) {
for(int i = 0; i < right.list.Count; i++) {
string key = (string)right.keys[i];
if(right[i].isContainer){
if(left.HasField(key))
MergeRecur(left[key], right[i]);
else
left.AddField(key, right[i]);
} else {
if(left.HasField(key))
left.SetField(key, right[i]);
else
left.AddField(key, right[i]);
}
}
} else if(left.type == Type.ARRAY && right.type == Type.ARRAY) {
if(right.Count > left.Count){
Debug.LogError("Cannot merge arrays when right object has more elements");
return;
}
for(int i = 0; i < right.list.Count; i++) {
if(left[i].type == right[i].type) { //Only overwrite with the same type
if(left[i].isContainer)
MergeRecur(left[i], right[i]);
else{
left[i] = right[i];
}
}
}
}
}
示例5: MergeRecur
static void MergeRecur(JSONObject left, JSONObject right) {
if(right.type == JSONObject.Type.OBJECT) {
for(int i = 0; i < right.list.Count; i++) {
if(right.keys[i] != null) {
string key = (string)right.keys[i];
JSONObject val = (JSONObject)right.list[i];
if(val.type == JSONObject.Type.ARRAY || val.type == JSONObject.Type.OBJECT) {
if(left.HasField(key))
MergeRecur(left[key], val);
else
left.AddField(key, val);
} else {
if(left.HasField(key))
left.SetField(key, val);
else
left.AddField(key, val);
}
}
}
}// else left.list.Add(right.list);
}
示例6: jsonFromCS
public JSONObject jsonFromCS()
{
JSONObject j = new JSONObject("{\"method\":\"hogemethod\"}");
Debug.Log( "j:" + j );
j.SetField( "params", new JSONObject( "[1,2,\"hoge\"]") );
Debug.Log( "j:" + j );
return j;
}
示例7: MergeRecur
/// <summary>
/// Merge object right into left recursively
/// </summary>
/// <param name="left">The left (base) object</param>
/// <param name="right">The right (new) object</param>
static void MergeRecur(JSONObject left, JSONObject right) {
if(left.type == Type.NULL)
left.Absorb(right);
else if(left.type == Type.OBJECT && right.type == Type.OBJECT) {
for(int i = 0; i < right.list.Count; i++) {
string key = right.keys[i];
if(right[i].isContainer) {
if(left.HasField(key))
MergeRecur(left[key], right[i]);
else
left.AddField(key, right[i]);
} else {
if(left.HasField(key))
left.SetField(key, right[i]);
else
left.AddField(key, right[i]);
}
}
} else if(left.type == Type.ARRAY && right.type == Type.ARRAY) {
if(right.Count > left.Count) {
return;
}
for(int i = 0; i < right.list.Count; i++) {
if(left[i].type == right[i].type) { //Only overwrite with the same type
if(left[i].isContainer)
MergeRecur(left[i], right[i]);
else {
left[i] = right[i];
}
}
}
}
}