<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Save json serialization in NOD (Named Object Dictionary) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/save-json-serialization-in-nod-named-object-dictionary/m-p/8647173#M23261</link>
    <description>&lt;P&gt;I'm trying to save a large string in Xrecord date. In my case I want to save a json serialization. But from what I noticed Xrecord Data has a string size limitation.&amp;nbsp;The string loses some of the content in XRecord.Data. My question is is there any way to save a large string in NOD? Or a way to save a file.json in NOD dictionary?&amp;nbsp;Or save a json file in the dwg database?&amp;nbsp;Or some better way to do this?&lt;/P&gt;
&lt;PRE&gt;        public static void WriteNod(string content)//json serialization
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                DBDictionary nod = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead);
                DBDictionary dbDict;
                using (DocumentLock dl = doc.LockDocument())
                {
                    try
                    {
                        dbDict = tr.GetObject(nod.GetAt(dictName), OpenMode.ForWrite) as DBDictionary;
                        foreach (DBDictionaryEntry entry in dbDict)
                            dbDict.Remove(entry.Key);
                    }
                    catch
                    {
                        nod.UpgradeOpen();
                        dbDict = new DBDictionary();
                        nod.SetAt(dictName, dbDict);
                        tr.AddNewlyCreatedDBObject(dbDict, true);
                    }
                    Xrecord xrec = new Xrecord();
                    ResultBuffer datas = new ResultBuffer();
                    datas.Add(new TypedValue((int)DxfCode.Text, content));
                    xrec.Data = datas;//here is the problem
                    dbDict.SetAt("Library", xrec);
                    tr.AddNewlyCreatedDBObject(xrec, true);
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;</description>
    <pubDate>Sat, 09 Mar 2019 11:07:40 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-03-09T11:07:40Z</dc:date>
    <item>
      <title>Save json serialization in NOD (Named Object Dictionary)</title>
      <link>https://forums.autodesk.com/t5/net-forum/save-json-serialization-in-nod-named-object-dictionary/m-p/8647173#M23261</link>
      <description>&lt;P&gt;I'm trying to save a large string in Xrecord date. In my case I want to save a json serialization. But from what I noticed Xrecord Data has a string size limitation.&amp;nbsp;The string loses some of the content in XRecord.Data. My question is is there any way to save a large string in NOD? Or a way to save a file.json in NOD dictionary?&amp;nbsp;Or save a json file in the dwg database?&amp;nbsp;Or some better way to do this?&lt;/P&gt;
&lt;PRE&gt;        public static void WriteNod(string content)//json serialization
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                DBDictionary nod = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead);
                DBDictionary dbDict;
                using (DocumentLock dl = doc.LockDocument())
                {
                    try
                    {
                        dbDict = tr.GetObject(nod.GetAt(dictName), OpenMode.ForWrite) as DBDictionary;
                        foreach (DBDictionaryEntry entry in dbDict)
                            dbDict.Remove(entry.Key);
                    }
                    catch
                    {
                        nod.UpgradeOpen();
                        dbDict = new DBDictionary();
                        nod.SetAt(dictName, dbDict);
                        tr.AddNewlyCreatedDBObject(dbDict, true);
                    }
                    Xrecord xrec = new Xrecord();
                    ResultBuffer datas = new ResultBuffer();
                    datas.Add(new TypedValue((int)DxfCode.Text, content));
                    xrec.Data = datas;//here is the problem
                    dbDict.SetAt("Library", xrec);
                    tr.AddNewlyCreatedDBObject(xrec, true);
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Mar 2019 11:07:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/save-json-serialization-in-nod-named-object-dictionary/m-p/8647173#M23261</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-03-09T11:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Save json serialization in NOD (Named Object Dictionary)</title>
      <link>https://forums.autodesk.com/t5/net-forum/save-json-serialization-in-nod-named-object-dictionary/m-p/8648101#M23262</link>
      <description>&lt;P&gt;You would need to break the string up into multiple elements and store each in the Xrecord. And then concatenate them when reading the data back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to save a large string in Xrecord date. In my case I want to save a json serialization. But from what I noticed Xrecord Data has a string size limitation.&amp;nbsp;The string loses some of the content in XRecord.Data. My question is is there any way to save a large string in NOD? Or a way to save a file.json in NOD dictionary?&amp;nbsp;Or save a json file in the dwg database?&amp;nbsp;Or some better way to do this?&lt;/P&gt;
&lt;PRE&gt;        public static void WriteNod(string content)//json serialization
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                DBDictionary nod = (DBDictionary)tr.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForRead);
                DBDictionary dbDict;
                using (DocumentLock dl = doc.LockDocument())
                {
                    try
                    {
                        dbDict = tr.GetObject(nod.GetAt(dictName), OpenMode.ForWrite) as DBDictionary;
                        foreach (DBDictionaryEntry entry in dbDict)
                            dbDict.Remove(entry.Key);
                    }
                    catch
                    {
                        nod.UpgradeOpen();
                        dbDict = new DBDictionary();
                        nod.SetAt(dictName, dbDict);
                        tr.AddNewlyCreatedDBObject(dbDict, true);
                    }
                    Xrecord xrec = new Xrecord();
                    ResultBuffer datas = new ResultBuffer();
                    datas.Add(new TypedValue((int)DxfCode.Text, content));
                    xrec.Data = datas;//here is the problem
                    dbDict.SetAt("Library", xrec);
                    tr.AddNewlyCreatedDBObject(xrec, true);
                }
                tr.Commit();
            }
        }&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2019 12:11:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/save-json-serialization-in-nod-named-object-dictionary/m-p/8648101#M23262</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2019-03-10T12:11:12Z</dc:date>
    </item>
  </channel>
</rss>

