I don't think it makes sense at all to "read" JSON data with XSLT.
Where do you get the data from? Are you calling an extension to get that? In any case I'd suggest you use an(other?) extension to parse the JSON and return whatever you need from it.
Otherwise, the only way you can handle JSON as input in XSLT is by direct string-manipulation, and that is a royal pain that shouldn't even be necessary.
But please tell us a little more about where the data comes from, how you're getting it into XSLT and what you actually need as output.
Hi
I will more than happy to hear more suggestions.
This is the scenario: I am using PDCalendar so my client would be able to create special events, my client asked me if I can show Hebrew date on the calendar.
Since the Hebrew date have a different order than the Gregorian calendar I need to get the Hebrew day and month for each day:
Does this mean you have to perform 30+ lookups every time you need to display the calendar? That is a lot of HTTP requests...
If you were able to call that service and get an XML file with a whole month worth of data, it would be very simple to do.
An alternative would maybe be to build a converter yourself that performed those lookups and collected them in a file that you could then use as lookup - then you'd be able to only do the many requests once every night or so (I don't have any clue as to how the Hebrew dates work, i.e., are they the same every year for a given date or do they change?)
Maybe there's another service that can give you a full calendar?
Anyway - using JSON data in XSLT will be marginally slower than just having an XML file.
Given no other choices, I'd render the standard calendar, and then use AJAX on the frontend to do the lookups - the Hebrew dates would only show for JavaScript enabled browsers, but maybe that's an acceptable caveat?
EDIT: I see the calendar service gives you a month of data - if only they provided XML output for that too...
Hi
Thanks for the help, I asked the calendar service guy if there is a chance to get the data VIA XML file so I won't have to call each day by HTTP.
Is there a way to convert the JSON data to xml file? and use it in my xslt?
can you show me a sample on how can I do such a thing?
Ans if you can show me an AJAX sample it would be very helpful :)
Thanks.
Reading json using xslt
Hi I need to read json data using xslt the json file look like this:
I need to get the "hebrew" value from the file.
Thanks
Hi Moran,
I don't think it makes sense at all to "read" JSON data with XSLT.
Where do you get the data from? Are you calling an extension to get that? In any case I'd suggest you use an(other?) extension to parse the JSON and return whatever you need from it.
Otherwise, the only way you can handle JSON as input in XSLT is by direct string-manipulation, and that is a royal pain that shouldn't even be necessary.
But please tell us a little more about where the data comes from, how you're getting it into XSLT and what you actually need as output.
/Chriztian
Hi I will more than happy to hear more suggestions. This is the scenario: I am using PDCalendar so my client would be able to create special events, my client asked me if I can show Hebrew date on the calendar. Since the Hebrew date have a different order than the Gregorian calendar I need to get the Hebrew day and month for each day:
This is an ex:
The service I am using is from this site
Since I already have the Gregorian date I only need to get the Hebrew date for each day and I am all set.
Anyone? I will be more then happy to provide more information :)
Hi Moran,
Does this mean you have to perform 30+ lookups every time you need to display the calendar? That is a lot of HTTP requests...
If you were able to call that service and get an XML file with a whole month worth of data, it would be very simple to do.
An alternative would maybe be to build a converter yourself that performed those lookups and collected them in a file that you could then use as lookup - then you'd be able to only do the many requests once every night or so (I don't have any clue as to how the Hebrew dates work, i.e., are they the same every year for a given date or do they change?)
Maybe there's another service that can give you a full calendar?
Anyway - using JSON data in XSLT will be marginally slower than just having an XML file.
Given no other choices, I'd render the standard calendar, and then use AJAX on the frontend to do the lookups - the Hebrew dates would only show for JavaScript enabled browsers, but maybe that's an acceptable caveat?
EDIT: I see the calendar service gives you a month of data - if only they provided XML output for that too...
/Chriztian
Hi Thanks for the help, I asked the calendar service guy if there is a chance to get the data VIA XML file so I won't have to call each day by HTTP. Is there a way to convert the JSON data to xml file? and use it in my xslt? can you show me a sample on how can I do such a thing?
Ans if you can show me an AJAX sample it would be very helpful :) Thanks.
Too late to the party for the original problem, but for reference, there is now a umbraco.library:JsonToXml extension that should solve the problem!
is working on a reply...