Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Not importing more than 256 characters #61

Closed
MatthewKosloski opened this issue Dec 28, 2017 · 2 comments
Closed

Not importing more than 256 characters #61

MatthewKosloski opened this issue Dec 28, 2017 · 2 comments

Comments

@MatthewKosloski
Copy link

MatthewKosloski commented Dec 28, 2017

Hello,

I'm trying to import the JSON from this URL.

I place the following in cell A1 after adding ImportJSON.gs to my spreadsheet:

=ImportJSON("https://matthewkosloski.me/foo.json")

It appears that not all the data is being imported.

The first column has all the data (all 256 characters of text).
The second column imports all of the data except for the period at the end (the 257th character).
The third column only imports up to the 256th character (cutting off at "digni").

This is the data that is being imported:

255 Chars 257 Chars 512 Chars
Iste eaque consectetur veritatis. Dolorum at, nihil numquam eius aliquam tenetur assumenda ut harum! Officia praesentium repellat rerum assumenda asperiores magnam aliquid inventore eaque perferendis debitis ad aspernatur blanditiis impedit, harum sit ap. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam impedit officia animi, cumque praesentium sed minima non aut, quisquam ex, esse deleniti perferendis cum nam perspiciatis explicabo ad! Accusamus vel ducimus non consequatur facere, nihil rec Deleniti ad debitis quo sed totam deserunt sequi voluptatum consequuntur, maiores non ipsa qui perspiciatis, nisi praesentium. Velit nisi ex, numquam cum ad quia ipsam rerum deleniti repellendus nemo explicabo esse? Iure, soluta et iusto maxime totam digni

This is what I should be getting:

255 Chars 257 Chars 512 Chars
Iste eaque consectetur veritatis. Dolorum at, nihil numquam eius aliquam tenetur assumenda ut harum! Officia praesentium repellat rerum assumenda asperiores magnam aliquid inventore eaque perferendis debitis ad aspernatur blanditiis impedit, harum sit ap. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magnam impedit officia animi, cumque praesentium sed minima non aut, quisquam ex, esse deleniti perferendis cum nam perspiciatis explicabo ad! Accusamus vel ducimus non consequatur facere, nihil rec. Deleniti ad debitis quo sed totam deserunt sequi voluptatum consequuntur, maiores non ipsa qui perspiciatis, nisi praesentium. Velit nisi ex, numquam cum ad quia ipsam rerum deleniti repellendus nemo explicabo esse? Iure, soluta et iusto maxime totam dignissimos dolore impedit sapiente, nam accusamus ratione, dolores ut praesentium, nulla sed quis voluptates tempora voluptatum. Consectetur in nisi delectus quasi optio impedit deleniti voluptates natus placeat dolorum dolore ad ullam alias illum maxime veni.

As you can see, there should be a period at the end of "rec" in column two, and column three has much more text.

I pasted my JSON in a linter and it says it's valid JSON. Are you able to recreate this issue?

It appears that it's only importing up to 256 characters of text.

Nevertheless, this is a really cool, valuable tool. Thanks for making it!

@jwframe
Copy link

jwframe commented Jan 12, 2018

In order to return the full data you must use the "noTruncate" parameter.

=ImportJSON("https://matthewkosloski.me/foo.json",,"noTruncate")

Refer to this section (specifically lines 44 & 50 of the importJSON.gs file).

Imports a JSON feed and returns the results to be inserted into a Google Spreadsheet. The JSON feed is flattened to create a two-dimensional array. The first row contains the headers, with each column header indicating the path to that data in the JSON feed. The remaining rows contain the data.

By default, data gets transformed so it looks more like a normal data import. Specifically:

  • Data from parent JSON elements gets inherited to their child elements, so rows representing child elements contain the values of the rows representing their parent elements.
  • Values longer than 256 characters get truncated.
  • Headers have slashes converted to spaces, common prefixes removed and the resulting text converted to title case.

To change this behavior, pass in one of these values in the options parameter:

  • noInherit: Don't inherit values from parent elements
  • noTruncate: Don't truncate values
  • rawHeaders: Don't prettify headers
  • noHeaders: Don't include headers, only the data
  • debugLocation: Prepend each value with the row & column it belongs in

Additional Comments:
Note the two commas between the "url" and the "noTruncate" parameter. If you wish to retrieve all the data in the file, you do not need a value between the commas. If you would like to only the data in a specific section... example: "i_am_512_chars_long" . Place this information between the two commas.

Example:
=ImportJSON("https://matthewkosloski.me/foo.json","/i_am_512_chars_long","noTruncate")

I hope that this is helpful to you. I am very grateful for the work that has been done by Trevor Lohrbeer, Brad Jasper, and others to create such a wonderful tool.

@maxiride
Copy link

Since this is solved you should mark the issue as closed =)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants