Reading JSON data from a URL
Hi all,
I have a requirement of reading JSON data from a particular URL and using one of the value to set one property in iView. I need some info on how to get JSON data from a URL and extracting attribute's value from it.
What are the APIs that can be used for this?Can anyone provide a solution/working example in Java for this?
I am working on EP 7.3.
Hi Tarun,
JAXB should work for you. Take a look at this example:
JAXB JSON Example | Examples Java Code Geeks
Regards,
Tobias
Similar Messages
-
Reading binary data from a URL
Below are 2 snippets of code that read data from a binary file. A small sample of the output is shown at the bottom of each code fragment. The first one uses the URL class to read a remote file. The ouput for this fragment is incorrect in some cases. The second uses a stream reader to read a local file (the output is correct in this case). Both fragments read the same file.
As you can notice, some of the bytes read are the same in both cases. Some others are not.
I hope you can suggest how I can fix my URL version.
Thanks for your help.
Miguel
Program A: Reads a remote file with URL
URL url = new URL("http:localhost//myfile.awg");
URLConnection connection = url.openConnection();
BufferedReader bin = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while(true) {
System.out.println(Integer.toHexString(bin.read()));
7d 3 0 0
22 30 3 3e
fd b9 2a 0
b2 2 0 1
Program B: Rads a local file
DataInputStream din = new DataInputStream(new BufferedInputStream
(new FileInputStream("c:\\inetpub\\wwwroot\\myfile.awg")));
while(true) {
System.out.println(Integer.toHexString(din.read()));
8e 3 0 0
99 30 3 3e
81 b9 2a 0
b2 2 0 1What can I use instead?
Thanks,
MiguelBufferedInputStream as in Program B. -
How to use the readLine() method when reading data from a URL?
Hello,
I have a URL which contains text input.
The only way to get the data from this URL is by opening a URL connection to it.
I would like to get the data from this URL but at the same time I would like to be able to use readLine() method of BufferedReader in order to read the data line by line.
My question is how do I combine between these two requirements in order to reed the data from the URL?
RoyHello Roy,
can you try out this code.
URL yahoo = new URL("http://www.yahoo.com/");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
Regards,
Mohan R -
Hi all,
i need the code that can fetch the data from another URL like i need the new from different site and put into my database and then website useing the jsp or u tell me in which and how.
thanks in advance.. URGENT
Waiting................................................ UR rpely..................Hi,
People generally ignore "URGENT" pleas on this forum... it's only urgent to you.
You probably want to do a search for "web scraping"... basically parsing HTML pages as XML, and extracting the results.
Recently dcminter posted a link to a very good article from the IBM website, which you should read.
http://www-128.ibm.com/developerworks/java/library/j-jtp03225.html
regards,
Owen -
Receive POST data from another URL and process using Struts
Hi there
We have a website and as of now we are receiving some data from another URL which is received as an appended part of the URL. My application uses Struts and we process the received data and send back a response.
Now my question is, I have been asked to change this behavior because there are more parameters now which cannot be passed through the URL. I am supposed to get the data from the other URL as POST data (as a form) and I have to create a new Struts action to receive this data, process it and send the response back to the requesting URL.
Please explain me how to do this using some example code snippets.
Thanks a lotLookup in XI is used to call the target data storage system and get data from there to your mapping programme.
In XI you can do Lookup in Message Mapping, Java Mapping and in XSLT Mapping. Previously Lookup in XI was system dependent. But now what ever the system are i.e. SAP system or non-sap system(Oracle,MS SQL etc) lookup API are same.
Overview of Lookup
- Lookups are used to identify/request the data from mapping program.
- It interrupt the process and looking for data which was stored in target system.
- It get that data and comeback to process and continue with that data.
Types of Lookups in XI
- JDBC Lookup: JDBC lookup is used for accessing data from database (non SAP).
- RFC Lookup: RFC lookup is used for accessing the SAP Data.
- SOAP Lookup: SOAP lookup is used for accessing data from Webservice
Steps to perform Lookup in Mapping
Import package com.sap.aii.mapping.lookup.*;
Create connection to the target Database system.
// Determine communication channel created in ID
Channel channel = null;
channel = LookupService.getChannel("DB-SYSTEM-NAME","DB-CHANNEL-NAME");
// Get system accessor for the channel.
DataBaseAccessor accessor = null;
accessor = LookupService.getDataBaseAccessor(channel);
Build the Query String.
Getting Result
// Execute Query and get the values.
DataBaseResult resultSet = null;
resultSet = accessor.execute(Query); -
I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?
Attachments:
try2.txt 2 KB
read_array.vi 21 KBThe problem is in the delimiters in your text file. By default, Read From Spreadsheet File.vi expects a tab delimited file. You can specify a delimiter (like a space), but Read From Spreadsheet File.vi has a problem with repeated delimiters: if you specify a single space as a delimiter and Read From Spreadsheet File.vi finds two spaces back-to-back, it stops reading that line. Your file (as I got it from your earlier post) is delimited by 4 spaces.
Here are some of your choices to fix your problem.
1. Change the source file to a tab delimited file. Your VI will then run as is.
2. Change the source file to be delimited by a single space (rather than 4), then wire a string constant containing one space to the delimiter input of Read From Spreadsheet File.vi.
3. Wire a string constant containing 4 spaces to the delimiter input of Read From Spreadsheet File.vi. Then your text file will run as is.
Depending on where your text file comes from (see more comments below), I'd vote for choice 1: a tab delimited text file. It's the most common text output of spreadsheet programs.
Comments for choices 1 and 2: Where does the text file come from? Is it automatically generated or manually generated? Will it be generated multiple times or just once? If it's manually generated or generated just once, you can use any text editor to change 4 spaces to a tab or to a single space. Note: if you want to change it to a tab delimited file, you can't enter a tab directly into a box in the search & replace dialog of many programs like notepad, but you can do a cut and paste. Before you start your search and replace (just in the text window of the editor), press tab. A tab character will be entered. Press Shift-LeftArrow (not Backspace) to highlight the tab character. Press Ctrl-X to cut the tab character. Start your search and replace (Ctrl-H in notepad in Windows 2000). Click into the Find What box. Enter four spaces. Click into the Replace With box. Press Ctrl-V to paste the tab character. And another thing: older versions of notepad don't have search and replace. Use any editor or word processor that does. -
How to read a data from USB port using JAVA
hi all,
i need to know how to read a data from USB port using java. any API are available for java ?.........please give your valuable ideas !!!!!!!!!
Advance Thanks!!You can do this. Please use this link
[http://www.google.co.in/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=uHu&q=java+read+data+from+usb+port&btnG=Search&meta=&aq=f&oq=]
What research did you do of your own? Have you done some testing application and tried yourself?? -
How to read the data from Excel file and Store in XML file using java
Hi All,
I got a problem with Excel file.
My problem is how to read the data from Excel file and Store in XML file using java excel api.
For getting the data from Excel file what are all the steps i need to follow to get the correct result.
Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
Thanks & Regards,
Sreenu,
[email protected],
india,If you want someone to do your work, please have the courtesy to provide payment.
http://www.rentacoder.com -
How to read the data from excel file and store into the table?
Hi All,
I have table with BLOB datatype contains a excel file. I have to read that data from excel and store into one table with all the fields in excel.
All the excel fields and my table columns are same.
Can you share with me how can acheive this using LOB's?
ThanksHi OraSuirya,
you can try with external tables .
syntax as follows
create table ext_table_csv (
i Number,
n Varchar2(20),
m Varchar2(20)
organization external (
type oracle_loader
default directory ext_dir
access parameters (
records delimited by newline
fields terminated by ','
missing field values are null
location ('file.csv')
reject limit unlimited;
For this you need to create directory
Directory Creation syntax:
create or replace directory ext_dir as 'D:\oracle\user_dir\ext_dir';
grant read, write on directory ext_dir to <User>;
please paste the excel file in the particular directory .
I hope this will help you.
Please correct me if I am wrong anywhere .
Thanks,
Tippu. -
Regarding reading the data from spool
Hi Experts,
How can i read the data from spool?
I need to read the data from the spool and should display on the screen?
Is there any FM to read the data from spool?
Sruthi.hi please use this..
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = v_spool
TABLES
buffer = it_spool
EXCEPTIONS
no_such_job = 1
not_abap_list = 2
job_contains_no_data = 3
selection_empty = 4
no_permission = 5
can_not_access = 6
read_error = 7 -
Regarding reading the data from the files without using Stremas
hai to all of u...
here i have a problem where i have to read the data from the files without using any streams.
please guide me how to do this one,if possible by giving with an example
Thanks & Regard
M.RamakrishnaSimply put, you can't.
By why do you need to? -
Reading aggregated data from a cube/multiprovider
Hi BI people
My project is currently looking for a functionmodule that reads aggregated data from a cube/multiprovider.
I already have a functionmodule that reads data from a cube and returns it in a flat format. I have debugged this, but have not found any flags that can enable the OLAP functionality needed to perform the aggregation. The functionmodule is "RSDRI_INFOPROV_READ_RFC".
The situation is that I need to apply the aggregation logic of a profit center hierrarchy to the data I read from RSDRI_INFOPROV_READ_RFC, this means manually replicating the the OLAP engine functionality (keyfigure aggregation exception, ect.) and this is not an option with the available time/budget.
Please have a look at the example below:
Say that I have a profit center hierarchy as displayed below (with postable nodes).
PC1 - $10
|---- PC2 - $30
|---- PC3 - $20
The data I'm getting back from the functionmodule RSDRI_INFOPROV_READ_RFC looks like this:
PC1 $10
PC2 $30
PC3 $20
But I need the data aggregated. An aggregation utilizing the hierarchy above will make the data look like this:
PC1 $60
PC2 $30
PC3 $20
Instead of building an aggregation program, it would be usefull if it was possible to extract aggregated data.
Any comments appreciated.
Regards
MartinThx Olivier,
The problem is that I need a functionmodule that can apply the OLAP aggregation for a hierarchy to the data outpu from RSDRI_INFOPROV_READ_RFC.
... or the best alternative would be if there were a fm/class that could provide me with the hierarchy aggregation of the data.
/Martin -
Reading the data from BLOB column
HI,
I have a table with following structure
Test_Mail(Attachment BLOB,Attachmentname varchar2(255),FileSize number)
The data in the table is like
Attachment|Attachmentname|FileSize
BLOB|test.txt|1236
I wants to read the data from the BLOB attachment in to new file.
can any one help me in doing this with plsql??
Thanks in advance,
Balaji tk.
Edited by: Balaji.tk on Jan 9, 2011 9:28 PMMay be something like this ?
DECLARE
l_file UTL_FILE.FILE_TYPE;
l_buffer RAW (32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_blob BLOB;
l_blob_len INTEGER;
BEGIN
-- Open the destination file.
l_file := UTL_FILE.FOPEN ('TEST_DIR', v_attachment_name, 'wb');
--This v_attachment_name can be selected from your table.
-- Get LOB locator
FOR rec IN (
SELECT attachment l_blob
FROM test_mail
--Your where condition to find the row.
--AND ROWNUM =1
LOOP
l_blob_len := DBMS_LOB.getlength (rec.l_blob);
-- Read chunks of the BLOB and write them to the file
-- until complete.
WHILE l_pos < l_blob_len
LOOP
DBMS_LOB.READ (rec.l_blob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw (l_file, l_buffer, FALSE);
l_pos := l_pos + l_amount;
END LOOP;
commit;
END LOOP;
-- Close the file.
UTL_FILE.FCLOSE (l_file);
EXCEPTION
WHEN OTHERS
THEN
-- Close the file if something goes wrong.
IF UTL_FILE.IS_OPEN (l_file)
THEN
UTL_FILE.FCLOSE (l_file);
END IF;
RAISE;
END; -
Reading the data from one component view into another component view
Hi All,
I have requirement to read the data from one component into another component while creating the service order. Here are the details.
Main View for Service order: BT116H_SRVO in that we have two assignment blocks like Organizational data(BTORGSET) and amount allocation(BTAMNTALL).This two blocks are two different component which are associated with main component(BT116H_SRVO).
I need to read the sales org data from component/View(BTORGSET/Orgsetdata) into Component/View(BTAMNTALL(HdrBillPlanDet) method DO_VALIDATE_INPUT.
I searched in SDN but all the posts are related to the data exchange between two views in same component. But My scenario is different as explained above.
Refer the attachments for the component link..
Please let me know how we can achieve this one..
Thanks,
Sapsar.Finally I was able to fix my code...My Mistakes were need to read the parent node above three levels and need to use the relation entity name while reading the data..
Below is the correction code
IF iv_index IS NOT INITIAL.
lr_iterator ?= collection_wrapper->get_iterator( ).
lr_current ?= lr_iterator->get_by_index( iv_index ).
lr_entity ?= lr_iterator->get_by_index( iv_index ).
ELSE.
lr_current = collection_wrapper->get_current( ).
ENDIF.
*loop back to root entity
WHILE lr_entity->get_name( ) NE 'BTAdminH'.
lr_entity = lr_entity->get_parent( ).
ENDWHILE.
*Get the related entity
IF lr_entity IS BOUND.
lr_collection ?= lr_entity->get_related_entities( iv_relation_name = 'BTHeaderOrgmanSet' ) .
IF lr_collection IS BOUND.
lr_orgset_m = lr_collection->get_current( ).
* lr_orgset = lr_orgset_m->get_related_entity( iv_relation_name = 'BTOrgSet' ).
lr_orgset = lr_orgset_m->get_property_as_string( 'SALES_ORG' ).
ENDIF.
ENDIF.
Thanks,
Sapsar. -
Reading the data from XML Source
Hi
i want to read the data from XML source file, and update the transaction information to another XML file. how we can do this in ADF, please help
Thanks
nidhiyou may use normal Java API to do that
http://www.javablogging.com/read-and-write-xml/
Maybe you are looking for
-
Repairing Boot Camp on a secondary hard drive
Hi, I managed to install Windows on a partition of a secondary hard drive with Winclone, but I am unable to boot on it. Now when i choose windows as startup device i get the "No bootable device --- insert boot disk and press any key" error. I played
-
Hello Apple community, I am having a problem. My grandpa has an ancient iPod nano 3rd gen 4gb. For some reason, whenever I plug the iPod into his computer, it crashes. Furthermore, with the iPod plugged in his computer it will BSOD again and restart.
-
GARAGEBAND window lockup!
I am running OS 10.5.3 and Garageband 4.1.2. My problem is in relation to this error I am receiving in the console. Every time I go to change tempo the window is frozen. Can't edit anymore and menus just flicker down and back up again. Is this relate
-
How to call a process in a report?
Hi Friends, Is there any standard Function Module or something like callprocess to call a process in the tcode hrasr_test _process ? With Regaeds, SHARMILA BRINDHA.M
-
Stop sound when same button is pressed
I'm a complete beginner to any type of programming, so I'm glad that I even got this small tiny script working without errors. I've been scouring the web for tutorials and help and I can't find any tutorial to help. But I know this is a Programming 1