public void Generate()
        {
            JsonArray jsonArray = new JsonArray();
            jsonArray.AddValue(new JsonValue());
            jsonArray.AddValue(new JsonValue(false));
            jsonArray.AddValue(new JsonValue(true));
            jsonArray.AddValue(new JsonValue((byte)1));
            jsonArray.AddValue(new JsonValue((decimal)2.5));
            jsonArray.AddValue(new JsonValue((double)0.7));
            jsonArray.AddValue(new JsonValue((float)1.4));
            jsonArray.AddValue(new JsonValue((int)6));
            jsonArray.AddValue(new JsonValue((long)16));
            jsonArray.AddValue(new JsonValue((short)2));
            jsonArray.AddValue(new JsonValue("\tbla"));
            jsonArray.AddValue(new JsonObject());
            jsonArray.AddValue(new JsonArray());

            Assert.AreEqual("[null,false,true,1,2.5,0.7,1.4,6,16,2,\"\\tbla\",{},[]]", jsonArray.ToString());
        }
        public JsonValue Serialize(object obj, JsonMapper mapper)
        {
            Invitation invitation = (Invitation)obj;

            JsonObject result = new JsonObject();
            result.AddValue("subject", new JsonValue(invitation.Subject));
            result.AddValue("body", new JsonValue(invitation.Body));

            JsonObject recipients = new JsonObject();
            JsonArray people = new JsonArray();
            JsonObject person = new JsonObject();
            if (invitation.Recipient.ID != null)
            {
                person.AddValue("_path", new JsonValue("/people/" + invitation.Recipient.ID));
            }
            else
            {
                person.AddValue("_path", new JsonValue("/people/email=" + invitation.Recipient.Email));
                person.AddValue("first-name", new JsonValue(invitation.Recipient.FirstName));
                person.AddValue("last-name", new JsonValue(invitation.Recipient.LastName));
            }
            JsonObject personValue = new JsonObject();
            personValue.AddValue("person", person);
            people.AddValue(personValue);
            recipients.AddValue("values", people);
            result.AddValue("recipients", recipients);

            JsonObject itemContent = new JsonObject();
            JsonObject request = new JsonObject();
            request.AddValue("connect-type", new JsonValue("friend"));
            if (invitation.Recipient.AuthToken != null)
            {
                string[] authToken = invitation.Recipient.AuthToken.Split(':');
                JsonObject authorization = new JsonObject();
                authorization.AddValue("name", new JsonValue(authToken[0]));
                authorization.AddValue("value", new JsonValue(authToken[1]));
                request.AddValue("authorization", authorization);
            }
            itemContent.AddValue("invitation-request", request);
            result.AddValue("item-content", itemContent);

            return result;
        }
        public JsonValue Serialize(object obj, JsonMapper mapper)
        {
            Message message = (Message)obj;

            JsonObject result = new JsonObject();
            result.AddValue("subject", new JsonValue(message.Subject));
            result.AddValue("body", new JsonValue(message.Body));

            JsonObject recipients = new JsonObject();
            JsonArray people = new JsonArray();
            foreach (string id in message.RecipientIds)
            {
                JsonObject person = new JsonObject();
                person.AddValue("_path", new JsonValue("/people/" + id));

                JsonObject personValue = new JsonObject();
                personValue.AddValue("person", person);
                people.AddValue(personValue);
            }
            recipients.AddValue("values", people);
            result.AddValue("recipients", recipients);

            return result;
        }