Jump to content
You must now use your email address to sign in [click for more info] ×

JSON error -- looking for help


Recommended Posts

Trying out Data Merge for the first time in Publisher. I checked my JSON code with an online validator to confirm its syntax but Publisher keeps giving me this error when I try to upload my file...

Error parsing JSON file:
in Json::Value::operator[](ArrayIndex): requires arrayValue

Does Publisher not accept JSON with blank arrays? Is that what this is saying?

Link to comment
Share on other sites

  • 1 month later...

This is simply infuriating! I have tried a lot of different JSON structures to get the data, but nothing works. I get the same error as TenTen71 or a "syntax" error, even though my file is fine. If there is some specific structure of a JSON file we should use, could we get the "recipe" in documentation for data merge? If it is not about structure, could someone confirm or deny that the problem exists?

Link to comment
Share on other sites

It might help if we had a sample JSON file that exhibits the error.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

3 minutes ago, BloodDrop said:

If it is not about structure, could someone confirm or deny that the problem exists?

I'm not sure whether this helps but Affinity doesn't parse JSON beyond the 1st level. 

From the help File:

  • For JSON files, obtained from web/mobile services or database export, only a single top-level array of objects (and values in those objects) are supported; lower level arrays and objects are not supported.

2017 27” iMac 4.2 GHz Quad-Core Intel Core i7 • Radeon Pr 580 8GB • 64GB • Ventura 13.6.4.

iPad Pro (10.5-inch) • 256GB • Version 16.4

Link to comment
Share on other sites

I am just more curious than anything else regarding the use of JSON files. I too have tried using them and come up with the same error. I have also searched the web with DuckDuckGo and found nothing other than the statement from Serif/Affinity saying the Merge function can use JSON files. No examples of it see to exist. What I would like to see are some (simple) example JSON files which do work.

Mac Pro (Late 2013) Mac OS 12.7.4 
Affinity Designer 2.4.1 | Affinity Photo 2.4.1 | Affinity Publisher 2.4.1 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Link to comment
Share on other sites

These files are so simple, it does not require any complicated files to recreate the problem. The most basic json file should work, even if resulting in a lacking data structure. With CSV you can simply put some words, separate them with commas, and you can see how it is interpreted by Publisher. Then you can make adjustments. In the json case, I don't even know how it is understood by the application. I started with the simplest example:

{
  "Name": "Test",
  "Mobile": "12345678",
  "mail": "atsomething"
}

I have tried making the whole thing an array using "[]" as the top level. I have tried changing the values into arrays. I have tried changing the names into an array. But nothing wanted to compile. I have even used a table-structure with the json syntax, knowing only the first level would be parsed.

I agree with Old Bruce, it would be enough if we got a working json file as a reference, instead we are trying to wrap our heads around it and wasting time.

Link to comment
Share on other sites

35 minutes ago, Old Bruce said:

I am just more curious than anything else regarding the use of JSON files. I too have tried using them and come up with the same error. I have also searched the web with DuckDuckGo and found nothing other than the statement from Serif/Affinity saying the Merge function can use JSON files. No examples of it see to exist. What I would like to see are some (simple) example JSON files which do work.

Here is a very simple example that works for me. The .zip contains a .afpub file and two forms of the same data file to be merged. One is a .csv file, and the other a .json file created by an online conversion program from the .csv file.

SimpleDataMerge.zip

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

1 minute ago, walt.farrell said:

Here is a very simple example that works for me. The .zip contains a .afpub file and two forms of the same data file to be merged. One is a .csv file, and the other a .json file created by an online conversion program from the .csv file.

 

Nothing here that I can see...

Mac Pro (Late 2013) Mac OS 12.7.4 
Affinity Designer 2.4.1 | Affinity Photo 2.4.1 | Affinity Publisher 2.4.1 | Beta versions as they appear.

I have never mastered color management, period, so I cannot help with that.

Link to comment
Share on other sites

12 minutes ago, BloodDrop said:

I started with the simplest example:

{
  "Name": "Test",
  "Mobile": "12345678",
  "mail": "atsomething"
}

 

Here is how the JSON file I converted from CSV ended up, and it works:

[
{"First":"Walt","Last":"Farrell","Telephone":"555"},
{"First":"Marjorie","Last":"Farrell","Telephone":"666"}
]

 

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

1 minute ago, Old Bruce said:

Nothing here that I can see...

Sorry. Look again.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

18 minutes ago, BloodDrop said:

I started with the simplest example:

{
  "Name": "Test",
  "Mobile": "12345678",
  "mail": "atsomething"
}

Yours will work if you put [ and ] around that whole thing:

[
{
  "Name": "Test",
  "Mobile": "12345678",
  "mail": "atsomething"
}
]

 

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

Ok, that is interesting :)

Thanks Walt, that does explain a lot. Apparently, we need an array ( [ ] ) in the first level, and then every "row" of our table is an object ( {} ) containing a field:value pair for each cell in the row.

Yep, this should definitely be included in documentation for Publisher.

Thanks again Walt, helpful as always ;)

 

Link to comment
Share on other sites

1 hour ago, BloodDrop said:

Yep, this should definitely be included in documentation for Publisher.

And it is.

See my earlier post.

From the help File:

  • For JSON files, obtained from web/mobile services or database export, only a single top-level array of objects (and values in those objects) are supported; lower level arrays and objects are not supported.

2017 27” iMac 4.2 GHz Quad-Core Intel Core i7 • Radeon Pr 580 8GB • 64GB • Ventura 13.6.4.

iPad Pro (10.5-inch) • 256GB • Version 16.4

Link to comment
Share on other sites

8 minutes ago, Seneca said:

And it is.

See my earlier post.

From the help File:

  • For JSON files, obtained from web/mobile services or database export, only a single top-level array of objects (and values in those objects) are supported; lower level arrays and objects are not supported.

No,no, I mean the file structure should be included or an example file. This definition alone is not clear enough. It is easy to interpret it as the correct answer, if you already have the answer :) Notice, the basic json structure meets the requirement as well, yet is not right for this application. Anyway, it works and I hope others will find the answer here useful.

Link to comment
Share on other sites

  • 1 month later...

Hi, I'm just new with Affinity products.

I don't know if you resolved this problem, but in my case the fusion doesn't recognise JSON files.

I have read this post and the documentation about the first level...

My file looks like the same Walt describes, as a collection of objects, with just one level, but this is not accepted 🤔

 

As a feature request with this system, it would be very cool to get JSON Data as an URL (HTTP Get), so that at the refreshment of the document always take the latest version of the customer's Data to place in it.

here a JSON file which gives an error on Line 1 / Char 1

If someone could explain me what's wrong in there, this will really help me.

Luc

data.json

Link to comment
Share on other sites

18 minutes ago, LS_67 said:

If someone could explain me what's wrong in there, this will really help me.

Your data was saved in UTF-8 (good) but with a BOM character (Byte Order Mark) as the first byte (bad).

Save it without the BOM and it will work.

data-nobom.json

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.