<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/</id><updated>2022-01-28T17:34:28.012000Z</updated><subtitle>Recent posts to http data in JSON format - encoding </subtitle><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=50#01ab" rel="alternate"/><published>2022-01-28T17:34:28.012000Z</published><updated>2022-01-28T17:34:28.012000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com15ece98035bfe14b37344f11cc59c9a45c5ee6f9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Excellent, glad to hear it.  If you're interested in contributing to the library you can contact me directly, my email address is scattered all over the documentation.  Some time in the future when I have some time I'd like to figure out how to allow for both STRING and WSTRING types in the same library.  Not sure how I'm going to do that yet without creating two entirely separate systems.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=25&amp;page=1#3c6e" rel="alternate"/><published>2022-01-28T17:13:57.586000Z</published><updated>2022-01-28T17:13:57.586000Z</updated><author><name>damian177</name><uri>https://forge.codesys.com/u/damian177/</uri></author><id>https://forge.codesys.com4dc56546976d46690ef5a072a9d87c49ec43693f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;It works! &lt;br/&gt;
I forgot  set my global variable GPL_JSON_16 in edited above line. Now it works.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=50#e127" rel="alternate"/><published>2022-01-28T16:12:43.746000Z</published><updated>2022-01-28T16:12:43.746000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com39e6cc4372f55c04db7c5bd182060f035fa7f3b0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;In that case, the value is set in JSON_TO_STRUCT, line 110&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;JSONVars&lt;/span&gt;&lt;span class="o"&gt;^[&lt;/span&gt;&lt;span class="n"&gt;jsonvarindex&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nl"&gt;AsString&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NameValue&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;obj_level&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;if you set a breakpoint here, you should be able to step through each name:value pair, and see what's contained in the NameValue array at the one that's not working.&lt;/p&gt;
&lt;p&gt;The NameValue array is populated in the .Value method, which we've already modified, line 65-70.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;temporary&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;SysMemCpy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="nl"&gt;pDest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ADR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;NameValue&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;obj_level&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="nl"&gt;pSrc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ADR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;JSONString&lt;/span&gt;&lt;span class="o"&gt;^[&lt;/span&gt;&lt;span class="n"&gt;value_start&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="nl"&gt;udiCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;MIN&lt;/span&gt;&lt;span class="p"&gt;(((&lt;/span&gt;&lt;span class="n"&gt;value_stop&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;value_start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;GPL_JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MAX_VALUE_SIZE&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Maybe something wrong with the size math?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=25&amp;page=1#7131" rel="alternate"/><published>2022-01-28T15:59:49.889000Z</published><updated>2022-01-28T15:59:49.889000Z</updated><author><name>damian177</name><uri>https://forge.codesys.com/u/damian177/</uri></author><id>https://forge.codesys.com8e163f51541feca4bb362f3bcad49301d0fab8b7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Both HMIVarAsString and AsString have truncated characters.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=50#b2ff" rel="alternate"/><published>2022-01-28T15:33:50.509000Z</published><updated>2022-01-28T15:33:50.509000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com7faf1257fbbebf01d228b8901421d7e4139c06cd</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I think it must be something in STRING_TO_JSONVALUE function.&lt;br/&gt;
If JSONVAR.HMIVarAsString is correct, that means the value is correct when JSONVAR.AsString is set.  Because all it's doing there is copying the value, since it's already a string.  I was using that for a certain HMI that couldn't accept properties, only variables.&lt;br/&gt;
So, you might want to set a breakpoint in JSONVAR.AsString.Set, and then step through STRING_TO_JSONVAR to see where the limiting is happening.&lt;br/&gt;
It might be useful to take out the {attribute 'hide'} from the InternalValue variable, so you can look at the actual bytes stored internally&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=25&amp;page=1#cf51" rel="alternate"/><published>2022-01-28T15:24:57.383000Z</published><updated>2022-01-28T15:24:57.383000Z</updated><author><name>damian177</name><uri>https://forge.codesys.com/u/damian177/</uri></author><id>https://forge.codesys.comb4c701d153036a2e694b64223170b87ab94fd22f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;ok, now it works.&lt;br/&gt;
but still cuts characters. For example I put WSTRING:&lt;br/&gt;
ŁŚĘóśuąQóśŚńńNŃ&lt;/p&gt;
&lt;p&gt;but after Parase  in JSON variable is :&lt;br/&gt;
"ŁŚĘóśuąQó["&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=50#0afd" rel="alternate"/><published>2022-01-28T15:06:19.300000Z</published><updated>2022-01-28T15:06:19.300000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.comb3131bd663eb370bf984adf87e793cecad4035f7</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Did you change it in CharString.Get as well?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=25&amp;page=1#05c4" rel="alternate"/><published>2022-01-28T15:00:51.700000Z</published><updated>2022-01-28T15:00:51.700000Z</updated><author><name>damian177</name><uri>https://forge.codesys.com/u/damian177/</uri></author><id>https://forge.codesys.coma440f4793e25282a81e1a65396eb1e87c516ed8b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt; udiCount:= (_Size+1) * 2&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;ta linia nie wpływa w ogóle na wynik&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=50#f1f1" rel="alternate"/><published>2022-01-28T14:48:15.384000Z</published><updated>2022-01-28T14:48:15.384000Z</updated><author><name>tvm</name><uri>https://forge.codesys.com/u/tvm/</uri></author><id>https://forge.codesys.com7cdc5b61e2f317858a12f712f9f250e5d4b72c36</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;OK, what about leaving Size the way it was, and changing:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;//put data into internal value&lt;/span&gt;
&lt;span class="err"&gt;SysMemCpy(&lt;/span&gt;
&lt;span class="err"&gt;    pDest:= ADR(_InternalValue), &lt;/span&gt;
&lt;span class="err"&gt;    pSrc:= ADR(CharString), &lt;/span&gt;
&lt;span class="err"&gt;    udiCount:= (_Size+1) * 2&lt;/span&gt;
&lt;span class="err"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I can't remember how Size is used elsewhere - it's probably something to do with whether it includes the trailing null character or not.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>http data in JSON format - encoding </title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c7d3ad3156/?limit=25&amp;page=1#8e90" rel="alternate"/><published>2022-01-28T14:42:24.049000Z</published><updated>2022-01-28T14:42:24.049000Z</updated><author><name>damian177</name><uri>https://forge.codesys.com/u/damian177/</uri></author><id>https://forge.codesys.com3dda9d487d588892aa52f183b4d74cf0d3537bb2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Effect is like in attachement. Last characters are bad decode ...&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>