Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using LitJson;
- using System;
- public class coba3 : MonoBehaviour {
- // Use this for initialization
- void Start () {
- string json = @"
- {
- ""Age1"" : 10,
- ""Age2"" : 20,
- ""Age3"" : 30
- }";
- string json1 = @"
- {
- ""Age1"" : 60,
- ""Age2"" : 50,
- ""Age3"" : -100
- }";
- JsonData thomasdata = JsonMapper.ToObject (json);
- JsonData mattdata = JsonMapper.ToObject (json1);
- Debug.Log(comparison (mattdata, thomasdata,10,2));
- }
- public class Person
- {
- // C# 3.0 auto-implemented properties
- public string Name { get; set; }
- public int Age { get; set; }
- }
- public bool comparison(JsonData input, JsonData target, int threshold, int maxerror)
- {
- string[] kunci = new string[target.Count];
- int x = 0, y = 0, z = 0;
- int jumsalah = 0;
- int[] beda = new int[target.Count];
- foreach (string key in target.Keys) {
- kunci [x] = key;
- x++;
- }
- for (x = 0; x < target.Count; x++) {
- y = (int)input [kunci [x]];
- z = (int)target [kunci [x]];
- beda [x] = Math.Abs(y - z);
- if (beda [x] > threshold)
- {
- jumsalah++;
- }
- }
- if (jumsalah < maxerror) {
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement