<?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 Re: JSON format in the dxf xRecord in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7739000#M27746</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem was the length of the result buffers. I had it set to&amp;nbsp; &lt;SPAN&gt;32768&lt;/SPAN&gt; which was the half of 65536&amp;nbsp;limit with the dwg format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Setting the string chunk size to 512 fixed the problem with the dxf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition if&amp;nbsp; { and } where replaced with Unicode acad seems just ignore the records. When the record&amp;nbsp;is starting with { error is produced.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jan 2018 10:02:13 GMT</pubDate>
    <dc:creator>antti.kujala</dc:creator>
    <dc:date>2018-01-31T10:02:13Z</dc:date>
    <item>
      <title>JSON format in the dxf xRecord</title>
      <link>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7735076#M27739</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are storing data as JSON format in the DBObjects&amp;nbsp;extension dictionaries. Everything is working well except when the dwg is saved as dxf. The saved dxf file cannot be opened by the autocad as the xrecord entries containing the JSON cannot be read. The AcDbXrecord in dxf looks something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;AcDbXrecord
280
     1
  1
{"Setups":[{"Name":"Default","Default":[1,2,4,8,16],"ID":"00000000-0000-0000-0000-000000000000","Steps":[]}],"SelectedID":"00000000-0000-0000-0000-000000000000"}
  0
XRECORD
  5
25B
102
{ACAD_REACTORS
330
25A
102
}
330
25A
100&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem seems to be the '{' and '}' characters int he JSON format. Is the only way to replace the characters in the JSON string with something else ? Or is there a better solution ?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 06:24:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7735076#M27739</guid>
      <dc:creator>antti.kujala</dc:creator>
      <dc:date>2018-01-30T06:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: JSON format in the dxf xRecord</title>
      <link>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7736639#M27740</link>
      <description>&lt;P&gt;Xrecord strings should be able to handle every character.&amp;nbsp; It could be the string formatting - are you handling all those interior double-quotes properly so it sees it as one string?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 15:32:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7736639#M27740</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2018-01-30T15:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: JSON format in the dxf xRecord</title>
      <link>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7737190#M27741</link>
      <description>&lt;P&gt;Are you getting any error during DXFIN, or when opening the DXF file ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there was problem reading the strings, I would expect it to manifest in the LISP (entmake) function as well, but it doesn't seem to have any problem with your json string:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Command: (setq strdata (getstring T))
{"Setups":[{"Name":"Default","Default":[1,2,4,8,16],"ID":"00000000-0000-0000-0000-000000000000","Steps":[]}],"SelectedID":"00000000-0000-0000-0000-000000000000"}
"{\"Setups\":[{\"Name\":\"Default\",\"Default\":[1,2,4,8,16],\"ID\":\"00000000-0000-0000-0000-000000000000\",\"Steps\":[]}],\"SelectedID\":\"00000000-0000-0000-0000-000000000000\"}"

Command: (princ strdata)
{"Setups":[{"Name":"Default","Default":[1,2,4,8,16],"ID":"00000000-0000-0000-0000-000000000000","Steps":[]}],"SelectedID":"00000000-0000-0000-0000-000000000000"}"

Command: (setq xrecord (entmakex (list (cons 0 "XRECORD") (cons 100 "AcDbXrecord") (cons 1 strdata))))
&amp;lt;Entity name: 7ffffb0c6e0&amp;gt;

Command: (entget xrecord)
((-1 . &amp;lt;Entity name: 7ffffb0c6e0&amp;gt;) (0 . "XRECORD") (330 . &amp;lt;Entity name: 0&amp;gt;) (5 . "286") (100 . "AcDbXrecord") (280 . 1) (1 . "{\"Setups\":[{\"Name\":\"Default\",\"Default\":[1,2,4,8,16],\"ID\":\"00000000-0000-0000-0000-000000000000\",\"Steps\":[]}],\"SelectedID\":\"00000000-0000-0000-0000-000000000000\"}"))

Command: (setq str (cdr (assoc 1 (entget xrecord))))
"{\"Setups\":[{\"Name\":\"Default\",\"Default\":[1,2,4,8,16],\"ID\":\"00000000-0000-0000-0000-000000000000\",\"Steps\":[]}],\"SelectedID\":\"00000000-0000-0000-0000-000000000000\"}"

Command: (eq str strdata)
T&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&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;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3451212"&gt;@antti.kujala&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are storing data as JSON format in the DBObjects&amp;nbsp;extension dictionaries. Everything is working well except when the dwg is saved as dxf. The saved dxf file cannot be opened by the autocad as the xrecord entries containing the JSON cannot be read. The AcDbXrecord in dxf looks something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;AcDbXrecord
280
     1
  1
{"Setups":[{"Name":"Default","Default":[1,2,4,8,16],"ID":"00000000-0000-0000-0000-000000000000","Steps":[]}],"SelectedID":"00000000-0000-0000-0000-000000000000"}
  0
XRECORD
  5
25B
102
{ACAD_REACTORS
330
25A
102
}
330
25A
100&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem seems to be the '{' and '}' characters int he JSON format. Is the only way to replace the characters in the JSON string with something else ? Or is there a better solution ?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 18:15:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7737190#M27741</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-01-30T18:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: JSON format in the dxf xRecord</title>
      <link>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7738618#M27742</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error comes with both&amp;nbsp;DXFIN or when opening the file with browser.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is clearly related to the { and } characters. Replacing those for example with their unicodes U+007B and U+007D fixes the problem. Unfortunately with this method the&lt;SPAN&gt;&amp;nbsp;unicodes&amp;nbsp;needs to be replaced to curly brackets &lt;/SPAN&gt;before deserializing the string back to an object.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;U+007B"Setups":[U+007B"Name":"Default","Default":[1,2,4,8,16],"ID":"00000000-0000-0000-0000-000000000000","Steps":[]U+007D],"SelectedID":"00000000-0000-0000-0000-000000000000"U+007D&lt;/PRE&gt;&lt;P&gt;Here is the dxf file attached, If you can figure out something from the file. I am using ACAD 2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 07:26:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7738618#M27742</guid>
      <dc:creator>antti.kujala</dc:creator>
      <dc:date>2018-01-31T07:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: JSON format in the dxf xRecord</title>
      <link>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7738780#M27743</link>
      <description>&lt;P&gt;It looks like the problem may not the curly-braces. The problem may be the length of the string. While it may not be a problem with DWG, it could be a problem with DXF.&amp;nbsp; To confirm that, write a DXF that contains some short json strings that are &amp;lt; 1024 characters long. If it still fails, then try again with shorter strings. I suspect the problem is the length of the strings, but in any event, that can't be solved. You can also convert the entire string to Base64 and then convert back after the DXFIN or when you read the Xrecord.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3451212"&gt;@antti.kujala&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error comes with both&amp;nbsp;DXFIN or when opening the file with browser.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is clearly related to the { and } characters. Replacing those for example with their unicodes U+007B and U+007D fixes the problem. Unfortunately with this method the&lt;SPAN&gt;&amp;nbsp;unicodes&amp;nbsp;needs to be replaced to curly brackets &lt;/SPAN&gt;before deserializing the string back to an object.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;U+007B"Setups":[U+007B"Name":"Default","Default":[1,2,4,8,16],"ID":"00000000-0000-0000-0000-000000000000","Steps":[]U+007D],"SelectedID":"00000000-0000-0000-0000-000000000000"U+007D&lt;/PRE&gt;&lt;P&gt;Here is the dxf file attached, If you can figure out something from the file. I am using ACAD 2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 08:42:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7738780#M27743</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-01-31T08:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: JSON format in the dxf xRecord</title>
      <link>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7738814#M27744</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the problem is due to the string length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The limit is&amp;nbsp; 2049 characters (see &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-2553CF98-44F6-4828-82DD-FE3BC7448113" target="_blank"&gt;&amp;gt;&amp;gt;here&amp;lt;&amp;lt;&lt;/A&gt;) and the xrecord which causes the error (starting line 3076) has 4775 characters (note there's another xrecord -starting line 3058- which contains curly brackets and did not throw an error).&lt;/P&gt;
&lt;P&gt;If you remove this xrecord, the dxf file can be loaded in AutoCAD without error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should split this string into several xrecords.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 08:53:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7738814#M27744</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-01-31T08:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: JSON format in the dxf xRecord</title>
      <link>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7738857#M27745</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;'s reply confirms that there's a max length on strings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You don't have to split the string into multiple Xrecords, just multiple fields within the same Xrecord. A single Xrecord has a theoretical size limit of 2GB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can write an integer field before you write multiple string fields, indicating how many string fields follow, if that makes things simpler. You can also bracket multiple string fields as a way of identifying them as being the contents of a single string split into multiple fields.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you're writing DXF files, then it's presumed that they're going to be read by non-AutoCAD or non-Autodesk products, the problem there is that unless you know what products are reading the files, and what specific limits they may have on DXF string data,&amp;nbsp;the best course of action is to avoid long strings and keep their length below the limit imposed by older DXF formats.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 09:13:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7738857#M27745</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-01-31T09:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: JSON format in the dxf xRecord</title>
      <link>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7739000#M27746</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem was the length of the result buffers. I had it set to&amp;nbsp; &lt;SPAN&gt;32768&lt;/SPAN&gt; which was the half of 65536&amp;nbsp;limit with the dwg format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Setting the string chunk size to 512 fixed the problem with the dxf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition if&amp;nbsp; { and } where replaced with Unicode acad seems just ignore the records. When the record&amp;nbsp;is starting with { error is produced.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 10:02:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/json-format-in-the-dxf-xrecord/m-p/7739000#M27746</guid>
      <dc:creator>antti.kujala</dc:creator>
      <dc:date>2018-01-31T10:02:13Z</dc:date>
    </item>
  </channel>
</rss>

