json.path.read encoding Maptool-1.5.14

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
stolkun
Kobold
Posts: 9
Joined: Fri Mar 27, 2020 4:30 pm

json.path.read encoding Maptool-1.5.14

Post by stolkun »

Hello there, so i have a problem with the macro parser to write some code because the macro parser don't have standard utf8 cause it can't read accent so for example with
[r: res = json.path.read(notes, "\$.[?(@.Classe == 'Prêtre' )]")]
it won't work and will throw out an exception because he can't read the accent but if i replace ê by ê it will not throw out exception but will not display any information because it's not the good string,
i know it was corrected in 1.6.0
rectificationi tested it with 1.6.1 and it doesn't work neither but is there anyway to make it work in 1.5.14? thanks in advance !

Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: json.path.read encoding Maptool-1.5.14

Post by Merudo »

Hi there! It's hard to know how to fix your issue for sure because we don't know what's in the "notes" json.

Maybe this will help you:

Code: Select all

[h: notes = json.set("{}", "Classe", "Pr&#234tre")]

[r: res = json.path.read(notes, "[?(@.Classe == 'Pr&#234tre' )]")]

stolkun
Kobold
Posts: 9
Joined: Fri Mar 27, 2020 4:30 pm

Re: json.path.read encoding Maptool-1.5.14

Post by stolkun »

Merudo wrote:
Sat Apr 18, 2020 10:00 am
Hi there! It's hard to know how to fix your issue for sure because we don't know what's in the "notes" json.

Maybe this will help you:

Code: Select all

[h: notes = json.set("{}", "Classe", "Pr&#234tre")]

[r: res = json.path.read(notes, "[?(@.Classe == 'Pr&#234tre' )]")]
If you need an example of my notes it was the notes in my Lib:Token with getNotes
it was under this format

[
{
"NOM": "Abaissement des eaux",
"Classe": "Prêtre"
}
]

it's not the complete format but that's the only part that i use in my macro and the problem being that the macro parser can't read the accent makes it impossible to do a simple search in function of the key "Classe" because if i want my key to be equal to "Prêtre" it will give out an exception

Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: json.path.read encoding Maptool-1.5.14

Post by Merudo »

Could you share a token that holds the text?

stolkun
Kobold
Posts: 9
Joined: Fri Mar 27, 2020 4:30 pm

Re: json.path.read encoding Maptool-1.5.14

Post by stolkun »

I attached the token with the notes and macro click on showSpells and you see it will give out "line 1:22: expecting '"', found 'Ã'" because "Prêtre" is written with accent and parser can't read it :/
Attachments
tok.rptok
(269.27 KiB) Downloaded 10 times

Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: json.path.read encoding Maptool-1.5.14

Post by Merudo »

Thank you!

A workaround is to store the accent in a variable (for example the Notes of another lib token). If you have the accent in a variable named "ecircon", you can then write

Code: Select all

[json.path.read(notes, "[?(@.Classe == 'Pr" + ecircon + "tre + ')]")]
I hope this can help you a little. In the meanwhile I'll be working on a better solution.

Post Reply

Return to “MapTool”