本文整理汇总了C#中org.Keys方法的典型用法代码示例。如果您正苦于以下问题:C# org.Keys方法的具体用法?C# org.Keys怎么用?C# org.Keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org
的用法示例。
在下文中一共展示了org.Keys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToProperties
/// <summary>Converts the JSONObject into a property file object.</summary>
/// <param name="jo">JSONObject</param>
/// <returns>java.util.Properties</returns>
/// <exception cref="JSONException"/>
/// <exception cref="org.json.JSONException"/>
public static java.util.Properties ToProperties(org.json.JSONObject jo)
{
java.util.Properties properties = new java.util.Properties();
if (jo != null)
{
System.Collections.Generic.IEnumerator<string> keys = jo.Keys();
while (keys.HasNext())
{
string name = keys.Next();
properties[name] = jo.GetString(name);
}
}
return properties;
}
示例2: ToString
/// <summary>Convert a JSONObject into a cookie list.</summary>
/// <remarks>
/// Convert a JSONObject into a cookie list. A cookie list is a sequence
/// of name/value pairs. The names are separated from the values by '='.
/// The pairs are separated by ';'. The characters '%', '+', '=', and ';'
/// in the names and values are replaced by "%hh".
/// </remarks>
/// <param name="jo">A JSONObject</param>
/// <returns>A cookie list string</returns>
/// <exception cref="JSONException"/>
/// <exception cref="org.json.JSONException"/>
public static string ToString(org.json.JSONObject jo)
{
bool b = false;
System.Collections.Generic.IEnumerator<string> keys = jo.Keys();
string @string;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
while (keys.HasNext())
{
@string = keys.Next();
if (!jo.IsNull(@string))
{
if (b)
{
sb.Append(';');
}
sb.Append(org.json.Cookie.Escape(@string));
sb.Append("=");
sb.Append(org.json.Cookie.Escape(jo.GetString(@string)));
b = true;
}
}
return sb.ToString();
}
示例3: ToString
/// <summary>Reverse the JSONML transformation, making an XML text from a JSONObject.</summary>
/// <remarks>
/// Reverse the JSONML transformation, making an XML text from a JSONObject.
/// The JSONObject must contain a "tagName" property. If it has children,
/// then it must have a "childNodes" property containing an array of objects.
/// The other properties are attributes with string values.
/// </remarks>
/// <param name="jo">A JSONObject.</param>
/// <returns>An XML string.</returns>
/// <exception cref="JSONException"/>
/// <exception cref="org.json.JSONException"/>
public static string ToString(org.json.JSONObject jo)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int i;
org.json.JSONArray ja;
string key;
System.Collections.Generic.IEnumerator<string> keys;
int length;
object @object;
string tagName;
string value;
//Emit <tagName
tagName = jo.OptString("tagName");
if (tagName == null)
{
return org.json.XML.Escape(jo.ToString());
}
org.json.XML.NoSpace(tagName);
tagName = org.json.XML.Escape(tagName);
sb.Append('<');
sb.Append(tagName);
//Emit the attributes
keys = jo.Keys();
while (keys.HasNext())
{
key = keys.Next();
if (!"tagName".Equals(key) && !"childNodes".Equals(key))
{
org.json.XML.NoSpace(key);
value = jo.OptString(key);
if (value != null)
{
sb.Append(' ');
sb.Append(org.json.XML.Escape(key));
sb.Append('=');
sb.Append('"');
sb.Append(org.json.XML.Escape(value));
sb.Append('"');
}
}
}
//Emit content in body
ja = jo.OptJSONArray("childNodes");
if (ja == null)
{
sb.Append('/');
sb.Append('>');
}
else
{
sb.Append('>');
length = ja.Length();
for (i = 0; i < length; i += 1)
{
@object = ja.Get(i);
if (@object != null)
{
if (@object is string)
{
sb.Append(org.json.XML.Escape(@object.ToString()));
}
else
{
if (@object is org.json.JSONObject)
{
sb.Append(ToString((org.json.JSONObject)@object));
}
else
{
if (@object is org.json.JSONArray)
{
sb.Append(ToString((org.json.JSONArray)@object));
}
else
{
sb.Append(@object.ToString());
}
}
}
}
}
sb.Append('<');
sb.Append('/');
sb.Append(tagName);
sb.Append('>');
}
return sb.ToString();
}
示例4: ToString
/// <summary>Convert a JSONObject into an HTTP header.</summary>
/// <remarks>
/// Convert a JSONObject into an HTTP header. A request header must contain
/// <pre>{
/// Method: "POST" (for example),
/// "Request-URI": "/" (for example),
/// "HTTP-Version": "HTTP/1.1" (for example)
/// }</pre>
/// A response header must contain
/// <pre>{
/// "HTTP-Version": "HTTP/1.1" (for example),
/// "Status-Code": "200" (for example),
/// "Reason-Phrase": "OK" (for example)
/// }</pre>
/// Any other members of the JSONObject will be output as HTTP fields.
/// The result will end with two CRLF pairs.
/// </remarks>
/// <param name="jo">A JSONObject</param>
/// <returns>An HTTP header string.</returns>
/// <exception cref="JSONException">
/// if the object does not contain enough
/// information.
/// </exception>
/// <exception cref="org.json.JSONException"/>
public static string ToString(org.json.JSONObject jo)
{
System.Collections.Generic.IEnumerator<string> keys = jo.Keys();
string @string;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
if (jo.Has("Status-Code") && jo.Has("Reason-Phrase"))
{
sb.Append(jo.GetString("HTTP-Version"));
sb.Append(' ');
sb.Append(jo.GetString("Status-Code"));
sb.Append(' ');
sb.Append(jo.GetString("Reason-Phrase"));
}
else
{
if (jo.Has("Method") && jo.Has("Request-URI"))
{
sb.Append(jo.GetString("Method"));
sb.Append(' ');
sb.Append('"');
sb.Append(jo.GetString("Request-URI"));
sb.Append('"');
sb.Append(' ');
sb.Append(jo.GetString("HTTP-Version"));
}
else
{
throw new org.json.JSONException("Not enough material for an HTTP header.");
}
}
sb.Append(CRLF);
while (keys.HasNext())
{
@string = keys.Next();
if (!"HTTP-Version".Equals(@string) && !"Status-Code".Equals(@string) && !"Reason-Phrase".Equals(@string) && !"Method".Equals(@string) && !"Request-URI".Equals(@string) && !jo.IsNull(@string))
{
sb.Append(@string);
sb.Append(": ");
sb.Append(jo.GetString(@string));
sb.Append(CRLF);
}
}
sb.Append(CRLF);
return sb.ToString();
}
示例5: GetNames
/// <summary>Get an array of field names from a JSONObject.</summary>
/// <returns>An array of field names, or null if there are no names.</returns>
public static string[] GetNames(org.json.JSONObject jo)
{
int length = jo.Length();
if (length == 0)
{
return null;
}
System.Collections.Generic.IEnumerator<string> iterator = jo.Keys();
string[] names = new string[length];
int i = 0;
while (iterator.HasNext())
{
names[i] = iterator.Next();
i += 1;
}
return names;
}