Re: Invalid JSON?

2019-06-03 Thread Arnaud de Montard via 4D_Tech


> Le 3 juin 2019 à 07:49, JOHN BAUGHMAN via 4D_Tech <4d_tech@lists.4d.com> a 
> écrit :
> 
> HI Keisuke,
> 
>   Perhaps I should know, but what is a BOM? 

BOM stands for byte order mark: 
In most text editor (BBEdit, notepad c++…) there's an option in the "save as" 
to add it or not. 

-- 
Arnaud de Montard 




**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Invalid JSON? - solved

2019-06-03 Thread JOHN BAUGHMAN via 4D_Tech
There is a gremlin in the response. I cannot see it in the debugger , but the 
leading character is not (. If I set it to the pasteboard and paste it the JSON 
Validator it disappears as well if I paste it into a text editor.

The following fixes it…

If (Substring($Response;1;1)#"{")   
Repeat 
$Response:=Delete string($Response;1;1)
Until (Substring($Response;1;1)="{") | ($Response="")
End if 

John


> On Jun 2, 2019, at 3:05 PM, JOHN BAUGHMAN via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> I am getting the following from zip-codes.com…
> 
> {
>   "item": {
>   "ID": "77252",
>   "Medicare_Rating_Area_ID": "1"
>   }
> }
> 
> The list under item: s much much longer. If I use JASON Parse it throws an 
> error….
> 
>   JSON malformed in line 1, position 1
> 
> If I run it in the JSON Validtor at https://jsonlint.com it comes up valid.
> 
> What’s up with that? Can I fix the response so that it validates in 4D?
> 
> Thanks,
> 
> John
> 
> 
> 
> John Baughman
> Kailua, Hawaii
> (808) 262-0328
> john...@hawaii.rr.com
> 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Invalid JSON?

2019-06-02 Thread JOHN BAUGHMAN via 4D_Tech
HI Keisuke,

Perhaps I should know, but what is a BOM? 

Using a BLOB for the response variable then converting to text did not 
delete the BOM. It did however reveal what it was…. ø

Using a BLOB has a couple of more steps the just passing a text 
variable.

I think the mystery has been solved and I have a good work around. 
Wonder if I should give the site some feedback about the problem.

Thanks,

John


> On Jun 2, 2019, at 5:08 PM, Keisuke Miyako via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> perhaps there is a BOM.
> 
> did you pass a C_TEXT to HTTP Request?
> 
> you might want to use a BLOB,
> then Convert to text (which will get rid of the BOM),
> then parse.
> 
> 2019/06/03 10:05、JOHN BAUGHMAN via 4D_Tech 
> <4d_tech@lists.4d.com>のメール:
> 
> JSON malformed in line 1, position 1
> 
> 
> 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Invalid JSON?

2019-06-02 Thread JOHN BAUGHMAN via 4D_Tech
John,

After posting I found that the problem was an unknown leading character 
which does not get copied to the pasteboard with SET TEXT TO PASTEBOARD. So the 
posted text would not throw an error.

John

> On Jun 2, 2019, at 5:03 PM, John DeSoi via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> What version of 4D? JSON Parse on what you provided below does not throw an 
> error with 4D 17.1.
> 
> John DeSoi, Ph.D.
> 
> 
> 
>> On Jun 2, 2019, at 8:05 PM, JOHN BAUGHMAN via 4D_Tech <4d_tech@lists.4d.com> 
>> wrote:
>> 
>> I am getting the following from zip-codes.com…
>> 
>> {
>>  "item": {
>>  "ID": "77252",
>>  "Medicare_Rating_Area_ID": "1"
>>  }
>> }
>> 
>> The list under item: s much much longer. If I use JASON Parse it throws an 
>> error….
>> 
>>  JSON malformed in line 1, position 1
> 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Invalid JSON?

2019-06-02 Thread Keisuke Miyako via 4D_Tech
 perhaps there is a BOM.

did you pass a C_TEXT to HTTP Request?

you might want to use a BLOB,
then Convert to text (which will get rid of the BOM),
then parse.

2019/06/03 10:05、JOHN BAUGHMAN via 4D_Tech 
<4d_tech@lists.4d.com>のメール:

JSON malformed in line 1, position 1



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Invalid JSON?

2019-06-02 Thread John DeSoi via 4D_Tech
What version of 4D? JSON Parse on what you provided below does not throw an 
error with 4D 17.1.

John DeSoi, Ph.D.



> On Jun 2, 2019, at 8:05 PM, JOHN BAUGHMAN via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> I am getting the following from zip-codes.com…
> 
> {
>   "item": {
>   "ID": "77252",
>   "Medicare_Rating_Area_ID": "1"
>   }
> }
> 
> The list under item: s much much longer. If I use JASON Parse it throws an 
> error….
> 
>   JSON malformed in line 1, position 1

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**