Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > About Return JSON

Forum

Search UsersRules
About Return JSON
#1
Just came
Points:: 0
Joined:: Oct 9, 2018

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;

Profile
#2
Interested
Points:: 0
Joined:: Dec 4, 2017

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

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.