Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sebastian Dammark 583 posts 1407 karma points
    Feb 08, 2016 @ 13:41
    Sebastian Dammark
    0

    Can't make JsonDropdownPicker give any output

    Just to play around and to learn the nuPickers I was toying around with these examples.

    http://goessner.net/articles/JsonPath/index.html#e3

    But I can't really get them to work. This gives me zero output:

    $..book[?(@.isbn)]
    

    But if I test it here (http://jsonpath.com) it works perfectly.

    Am I doing something wrong or is there a logical explanation ? I'm using 'isbn' as key and 'title' as label.

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 08, 2016 @ 14:06
    Hendy Racher
    100

    Hi Sebastian,

    Thanks for the feedback, I've just tried creating a Json DropDownPicker using the JSON:

    { "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } ], "bicycle": { "color": "red", "price": 19.95 } } }
    

    with the following configuration values:

    • JSONPath: $..book[?(@.isbn)]
    • Key JSONPath: isbn
    • Label JSONPath: title

    and I get a drop down with two books: Moby Dick and The Lord of the Rings (the two books that isbn numbers)

    Can you see the AJAX call the drop down uses to get it's data ?

    Request Payload:

    {"config":{"dataSource":{"apiController":"JsonDataSourceApi","jsonPath":"$..book[?(@.isbn)]","keyJsonPath":"isbn","labelJsonPath":"title","url":"http://nupickers.local/jsondatasourcea/"},"relationMapping":null,"saveFormat":"csv"}}
    

    Response: (which does seem a bit odd with a the )]}', prefix !)

    )]}', [{"key":"0-553-21311-3","label":"Moby Dick"},{"key":"0-395-19395-8","label":"The Lord of the Rings"}]
    

    (BTW, for testing I'm using an Umbraco node with a textbox multiple for the JSON, and a template to render that JSON out, then using that internal url)

    Thanks, Hendy

  • Sebastian Dammark 583 posts 1407 karma points
    Feb 09, 2016 @ 16:08
    Sebastian Dammark
    0

    I can see that I'm way behind on the updates :) That's probably my problem.

  • Sebastian Dammark 583 posts 1407 karma points
    Feb 10, 2016 @ 09:38
    Sebastian Dammark
    0

    Hi Hendy.

    I've upgraded to latest version of nuPickers.

    I can make the bookstore example work, but when I change to another JSON source it goes haywire. The new source validates as valid JSON.

    I have no idea what I', doing wrong here.

    JSON: https://www.dropbox.com/s/bfw8sgb6yhhl44z/categories.json?dl=0

    JSONpath: $..translations[?(@.source_type)]

    key: id

    value: title

    {"config":{"dataSource":{"apiController":"JsonDataSourceApi","jsonPath":"$..translations[?(@.source_type)]","keyJsonPath":"id","labelJsonPath":"title","url":"~/json/local_categories.json"},"relationMapping":null,"saveFormat":"csv"}}
    
  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 10, 2016 @ 11:24
    Hendy Racher
    0

    Hi Sebastian,

    Just tried with that JSON (using locally served) and the new configuration values, and I get a drop down with the options:

    • Title
    • Title 2
    • Title 4
    • Title 5
    • Title 7
    • Title 8
    • Title 10
    • Title 11
    • Title 13
    • Title 15

    Do you see any response from the AJAX call ? (I'm guessing here, but I wonder if it has anything to do with the ~/ prefix)

    {"config":{"dataSource":{"apiController":"JsonDataSourceApi","jsonPath":"$..translations[?(@.source_type)]","keyJsonPath":"id","labelJsonPath":"title","url":"http://nupickers.local/jsondatasourcea/"},"relationMapping":null,"saveFormat":"csv"}}
    

    Is there anything in the error log ?

    Thanks, Hendy

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies