• Resolved comziz

    (@comziz)


    Hello I’m trying to import json from url (https://www.btcturk.com/api/ticker) but I get the data invalid error.

    I validated the json format from another website, but i can not seem to import it.

    I would really like to import the data from there;

    {“high”:1565.01,”last”:1536.90,”timestamp”:1388632896.0,”bid”:1540.0,”volume”:50.76,”low”:1534.00,”ask”:1552.00}

    like this;
    column1 column2
    High….value
    last….value
    time….date
    bid…..value
    low…..value

    isn’t there anyway to accomplish this with this beautiful plugin?

    http://wordpress.org/plugins/tablepress/

Viewing 15 replies - 1 through 15 (of 25 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    Unfortunately, it is not possible to just import any JSON formatted string into TablePress. The JSON format that TablePress is limited to two-dimensional arrays, i.e. to JSON of the form:

    [["high","value"],["last","value"],["time","value"],["bid","value"],["low","value"]]

    You would have to re-format the JSON code to that format first.

    (Note: In the next version of TablePress, your example code will actually be imported as a one column table (just the values). If you want to test that, just install the current TablePress developer version from http://tablepress.org/download/tablepress-dev.zip .)

    Regards,
    Tobias

    Thread Starter comziz

    (@comziz)

    Dear Tobias

    Thank you so much for your rapid response & solution.

    I just tried the developer version and it works just like a charm.

    I am so excited about the next version of TablePress!

    The only problem for users, might be the “timestamp” or “date” values. Which is imported as it is. But I assume this field id name would change from source to source and it would nearly be impossible to implement a converter, unless there’s and option to select the date / time related fields as time values.

    But in my case this doesn’t matter because I’m only using the “ask” & “bid” fields, and tablepress brings them to me very easily.

    Thank you so much again, and I wish you continuous success on your plugin.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! πŸ™‚ Good to hear that this helped!

    Having a converter for the timestamp or date is indeed not possible reliably. I’d rather follow the philosophy of not changing the imported data, but leave it as it is in the import source.

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

    Thread Starter comziz

    (@comziz)

    Sorry that I wrote in haste above but I think I’m having some problems.

    I added this table to a widget and I just noticed that the json data is not updated when I refresh the page.

    If I can’t show these values in real-time, then unfortunately this won’t work for me. =(

    Did I miss something or some settings?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    well, that’s expected… The tables are only imported once, there’s no automatic update.
    You might however want to take a look at the TablePress Extension from http://tablepress.org/extensions/table-auto-import/ which can be used for something like that (not a real-time update though).
    If you really need real time data, you’ll have to use a custom PHP solution.

    Regards,
    Tobias

    Thread Starter comziz

    (@comziz)

    =( I see..

    But still Tobias, thank you so much for your care and this wonderful plugin.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    sure! I hope that TablePress is still useful to you!

    Best wishes,
    Tobias

    Trying to create a new table with a JSON URL source. The service is changed and now returns a 2D array rather than object[] with column names in the first row. However, I keep getting an error that the data is in the wrong format. Right now it is:

    [
    [ “Column1”, “Column2”, “Column3” ],
    [ “Value1”, “Value2”, “Value3” ],

    ]

    Is there a problem that you see? For development purposes I am running the source service calls locally as localhost:port, does that make a difference?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I just tried importing

    [
    [ "Column1", "Column2", "Column3" ],
    [ "Value1", "Value2", "Value3" ],
    [ "Value1", "Value2", "Value3" ]
    ]

    (via the “Direct Input” method and didn’t have any problems with that.

    Are you using TablePress 1.4? That contains some changes to JSON import so that your format shouldn’t be an issue.

    Regards,
    Tobias

    Thanks for the reply.

    TablePress 1.4 is my current version. I just verified and WP is 3.9.1.

    Does the URL require a JSON file?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    then the import of the JSON format that you posted should work without problems…
    What happens if you paste the JSON that the source service provides into the “Direct Input” field, or if you download the file and then use the “File Upload” method?

    Regards,
    Tobias

    Manual Input did work with the raw data returned, interesting. Unfortunately that method will not work since the grids must read updated data at these services.

    Is there any way to do grouping with TablePress?

    Another question, is there any AJAX related plugin that should be installed for this type of data retrieval?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no, an AJAX plugin is not necessary. The Automatic Table Update Extension might be helpful, for the regular import: http://tablepress.org/extensions/table-auto-import/

    Now, if the direct input method works, I can only assume that something in the HTTP request to the service goes wrong. So, this might indeed be related to the service running on localhost — especially, if the server that WordPress is running on is not on that localhost.

    What do you mean with “grouping”?

    Regards,
    Tobias

    Vielen Dank fuer Ihre Professionalitaet!

    Thanks for the reference, I plan on using the auto update.

    I added in some extra logging so that I could see what was going on and the data was being received, but there was an error that followed that I am researching. I believe it might be a plugin conflict, but not sure yet. The logging stopped working now so I have to get that back up. Once I find out I will post my results. Thanks again for your help, it is really a great plugin!

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Invalid import data – Json – from URL’ is closed to new replies.