Author Topic: Escaping the brace character in text exports  (Read 69 times)

Offline Skids

  • Newcomer
  • *
  • Posts: 21
    • View Profile
Escaping the brace character in text exports
« on: November 19, 2024, 09:17:11 AM »
Hi,
I am attempting to produce a text output file that is in JSON format.  Unfortunately JSON uses the brace characters {} to enclose records.  In some places the backslash is used to escape the next character but it does not seem to work on text export.

My non-working text export set up is:
Code: [Select]
  {
        "thumb_img": "{clientweb}/{filenamebase}_Thumb.jpg",
        "full_img": "{clientweb}/{filename}",
        "thumb_width": "",
        "thumb_height": "",
        "full_width": "",
        "full_height": "",
        "sourceset": "",
        "alt_text": "",
        "thumb_content": "{headline}",
        "full_content": "{caption}",
        "blackout": "",
        "featured": "",
        "date": "date",
        "tags": "Keywords",
        "href": "",
        "structured_data": "",
     },

Unfortunately the leading brace prevents the first variable {clientweb} from being decoded.

Any ideas?

best wishes
S

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25019
    • View Profile
    • Camera Bits, Inc.
Re: Escaping the brace character in text exports
« Reply #1 on: November 19, 2024, 09:41:02 AM »
Hi,
I am attempting to produce a text output file that is in JSON format.  Unfortunately JSON uses the brace characters {} to enclose records.  In some places the backslash is used to escape the next character but it does not seem to work on text export.

Unfortunately the leading brace prevents the first variable {clientweb} from being decoded.

Any ideas?

I suggest using some other characters for the opening and closing braces, and then post processing with a text editor or a script to find and replace those characters with the open and closing braces.

-Kirk

Offline Skids

  • Newcomer
  • *
  • Posts: 21
    • View Profile
Re: Escaping the brace character in text exports
« Reply #2 on: November 19, 2024, 09:47:59 AM »
Thanks Kirk.  I had thought of doing exactly that using the tilde character ~ but hoped I could avoid the additional steps.

S

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25019
    • View Profile
    • Camera Bits, Inc.
Re: Escaping the brace character in text exports
« Reply #3 on: November 19, 2024, 09:57:27 AM »
Thanks Kirk.  I had thought of doing exactly that using the tilde character ~ but hoped I could avoid the additional steps.

You'll need to choose two different characters because you'll need them to be replaced with two different characters ( { and } ).

-Kirk