About Return JSON

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Oct 9, 2018
Company: Ötüken Teknoloji Araştırma Geliştirme Eğitim Hizmetleri Ticaret Limited Şirketi

Hello.

I have a catalog table.
I want to list all records with JSON format.
Is there a short way to do this?



I'm doing it like this.

Query = New Query;
Query.Text =
".... .. . . . . . . . .. . ";

QueryResult = Query.Execute();

SelectionDetailRecords = QueryResult.Select();

newarray= New Array;
While SelectionDetailRecords.Next() Do
arraystrc= New Structure;

arraystrc.Insert("KEY",SelectionDetailRecords["FIELD"]);
..
..
..

newarray.Add(arraystrc);
EndDo;


JSONWriter = New JSONWriter;
JSONWriterSettings =JSONWriter = New JSONWriter;
JSONWriter.SetString();

WriteJSON(JSONWriter, newarray);
Result = JSONWriter.Close();

         
Response = New HTTPServiceResponse(?(True, 200, 404));
Response.SetBodyFromString(Result, TextEncoding.System);  
Return Response;

 
#2
People who like this:0Yes/0No
Interested
Rating: 16
Joined: Dec 4, 2017
Company:

Dear Erdoğan Uğuz,

Also, you can take a look at examples of writing JSON-formatted data in this article:

https://1c-dn.com/blogs/techblog/49/

Best regards,
Vladimir Gurov

1C Company support team
 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.