JSONObject.Create C# (CSharp) Method

Create() public static method

Create a JSONObject by parsing string data
public static Create ( string val, int maxDepth = -2, bool storeExcessLevels = false, bool strict = false ) : JSONObject,
val string The string to be parsed
maxDepth int The maximum depth for the parser to search. Set this to to 1 for the first level, /// 2 for the first 2 levels, etc. It defaults to -2 because -1 is the depth value that is parsed (see below)
storeExcessLevels bool Whether to store levels beyond maxDepth in baked JSONObjects
strict bool Whether to be strict in the parsing. For example, non-strict parsing will successfully /// parse "a string" into a string-type
return JSONObject,
	public static JSONObject Create(string val, int maxDepth = -2, bool storeExcessLevels = false, bool strict = false)
	{
		JSONObject obj = Create();
		obj.Parse(val, maxDepth, storeExcessLevels, strict);
		return obj;
	}
	public static JSONObject Create(AddJSONConents content)

Same methods

JSONObject::Create ( ) : JSONObject,
JSONObject::Create ( AddJSONConents content ) : JSONObject,
JSONObject::Create ( string>.Dictionary dic ) : JSONObject,
JSONObject::Create ( Type t ) : JSONObject,
JSONObject::Create ( bool val ) : JSONObject,
JSONObject::Create ( float val ) : JSONObject,
JSONObject::Create ( int val ) : JSONObject,

Usage Example

Example #1
0
            public HTTPResponse.Builder ToHTTPResponseBuilder()
            {
                if (!Timestamp.HasValue)
                {
                    Timestamp = DateTime.UtcNow;
                }

                HTTPResponseBuilder.Server = Request.HTTPRequest.HTTPServer.DefaultServerName;
                HTTPResponseBuilder.Date   = Timestamp.Value;
                HTTPResponseBuilder.AccessControlAllowOrigin = "*";
                HTTPResponseBuilder.Connection = "close";

                if (Request.HTTPRequest.HTTPMethod != HTTPMethod.OPTIONS)
                {
                    HTTPResponseBuilder.ContentType = HTTPContentType.JSON_UTF8;

                    if (HTTPResponseBuilder.Content == null)
                    {
                        HTTPResponseBuilder.Content = JSONObject.Create(

                            Data != null
                                                              ? new JProperty("data", Data)
                                                              : null,

                            new JProperty("status_code", StatusCode ?? 2000),

                            StatusMessage.IsNotNullOrEmpty()
                                                              ? new JProperty("status_message", StatusMessage)
                                                              :  null,

                            AdditionalInformation.IsNotNullOrEmpty()
                                                              ? new JProperty("additionalInformation", AdditionalInformation)
                                                              : null,

                            RequestId.HasValue
                                                              ? new JProperty("requestId", RequestId.Value.ToString())
                                                              : null,

                            CorrelationId.HasValue
                                                              ? new JProperty("correlationId", CorrelationId.Value.ToString())
                                                              : null,

                            new JProperty("timestamp", (Timestamp ?? DateTime.UtcNow).ToIso8601())

                            ).ToUTF8Bytes();
                    }
                }

                HTTPResponseBuilder.Set("X-Request-ID", Request.RequestId).
                Set("X-Correlation-ID", Request.CorrelationId);

                HTTPResponseBuilder.SubprotocolResponse = this;

                return(HTTPResponseBuilder);
            }
All Usage Examples Of JSONObject::Create