How to store JSON in RavenDB?

I want to take existing data and put it in RavenDB.

My existing data was in XML format, so I converted it to JSON.

What should be my next step? Can I save it in RavenDB as it is? Do I need to create new objects for storage?

Thanks in advance!

+5
source share
2 answers

I believe that your json data represents data from your application domain and you want classes with properties to work with this data in your application, right?

, , , RavenDB, , RavenDB.

?

+1

RavenDB RavenDB Client, . /// .

JSON RavenDB HTTP API, , " " , ( ) "curl".

.NET:

var url = string.Format("http://ravendb-server:8080/databases/{0}/docs/{1}", databaseName, docId);
var webRequest = System.Net.HttpWebRequest.CreateHttp(url);
webRequest.Method = "PUT";
webRequest.ContentType = "application/json";
webRequest.Headers["Raven-Entity-Name"] = entityName;
var stream = webRequest.GetRequestStream();
using (var writer = new System.IO.StreamWriter(webRequest.GetRequestStream()))
{
    writer.Write(json);
}
var webResponse = webRequest.GetResponse();
webResponse.Close();

JSON . URL, Raven-Entity-Name.

, , Raven-Clr-Type Last-Modified, .

+5

All Articles