나는 귀하의 경우에 최고의 아이 솔즈의 아이디어라고 생각합니다. 데이터베이스와 PHP를 얻으려면 데이터베이스 자체에 데이터를 저장하는 방법이 필요합니다. 이렇게하면 완전히 새로운 웜을 열 수 있습니다. 물론 데이터베이스 + 서버 측 프론트 엔드는 업계 표준이지만 사용자 요구 사항에 비해 크기가 큽니다.
간단한 텍스트 파일에서 JSON을 읽을 때 JSON을 표시하는 방법을 배우는 것이 더 쉽습니다. 이 코드는 한 번만 작성하면됩니다.
변경 사항이있을 때마다 간단한 워크 플로를 사용할 수 있습니다. Excel을 사용하여 미리 녹음 된 형식을 사용하여 이벤트를 입력합니다. 그런 다음 Excel 파일을 .csv로 내 보냅니다. 작은 프로그램을 사용하여 CSV를 읽고이를 JSON에 직렬화하십시오. 출력을 서버의 미리 지정된 위치로 복사하십시오. 다 준비 됐어.
누군가가 부재중에 사이트를 업데이트해야한다면 Excel, 변환 도구 (작은 크기) 및 서버 암호 만 있으면됩니다. 이 대답의 끝에서 변환 도구의 코드를 게시하고 있습니다.
또는 코드를 사용하여 ASP .NET WebForms 프로젝트를 만들 수 있습니다. 코드에 의해 생성 된 객체를 직렬화하는 대신에를 만들 수 있습니다.aspx 페이지 및 서버 측 코드를 사용하여 데이터를 표시합니다. 그러나 이것은 몇 가지 단점이 있습니다.
- .NET 웹 양식은 자바 스크립트보다 가파른 학습 곡선을 가지고 있으며, 그 결과 코드는 아마 당신이 바로 그것을 할 방법을 알고하지 않는 CSS와 스타일 어려운 서버 측 컨트롤을 사용합니다.
- 자신의 서버 대신 저렴한 호스팅 패키지를 사용하는 경우 공급자에게 서버에 필요한 .net 버전이 있는지 확인해야합니다. 또한 일반적으로 .net 웹 프로젝트에 포함 된 모든 라이브러리 때문에 더 많은 공간을 차지할 것입니다.
- 입력 데이터의 구조가 변경되지 않으면 변환기를 한 번 컴파일하고 블랙 박스로 처리하기 시작할 수 있습니다. 내용 표시 방법에 대한 변경 사항은 JSON 읽기 코드에서 작성하고 브라우저에서 직접 디버깅 할 수 있습니다. .net 솔루션의 경우 Visual Studio 설치를 계속해야합니다.
- .net webforms은 미래 보장 기술이 아닙니다. Microsoft는 새롭고 편리한 웹 기술인 .NET MVC를 만들었으므로 이제는 오래된 기술을 배우기 시작할 것을 제안하지 않습니다. 반면 MVC가 정적 페이지와 동적 페이지를 쉽게 섞을 수 없기 때문에 기존 정적 페이지가 이미있는 경우이 프로젝트 MVC를 만드는 것은 좋은 생각이 아닙니다. 아마도 콘텐츠를 사용할 수는 있지만 전체 라우팅 시스템을 다시 작성하고 모든 내부 링크를 교체해야합니다. 여기
는 JSON에 CSV로 변환하는 C#을 appliaction에 대한 코드입니다. 컴파일되면 DataSource.csv라는 CSV와 동일한 디렉토리에 .exe 파일을 저장하십시오. 더블 클릭하십시오. 동일한 디렉토리에 autoOutput.json이라는 새 파일이 생성됩니다. .csv 파일의 각 행은 event name; venue; date; cost;
형식으로 작성되어야합니다. 당신은 cost
의 오른쪽에있는 Excel에서 주석 또는 유사 항목을 추가 할 수 있습니다, 그들은 삭제됩니다. 줄의 순서는 중요하지 않습니다. 이벤트 이름이 고유 한 경우 시작되는 모든 장소와 날짜는 해당 이벤트에 속한 것으로 해석됩니다. 이벤트 이름과 장소의 조합이 고유 한 경우 모든 날짜는 해당 장소의 해당 이벤트에 대한 것으로 해석됩니다.
너무 짧아서 어떤 행을 읽을 수 없었는지에 대한 정보는 제공하지 않습니다. 파일에 추가하거나 내용을 경고와 교환 할 수 있습니다. 그런 다음 변환을 수행하는 사람은 경고가 없거나 파일에 남겨 둘 수있을 때까지 CSV를 조작해야하지만 표시를 위해로드 할 때는 무시하십시오.
이 특히 크롬과 IE의 보안 문제를 던질 것으로 보인다
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web.Script.Serialization;
namespace ElendilEvents2JSON
{
public class Event
{
public String Name { get; set; }
public List<EventInVenue> venues { get; set; }
}
public class EventInVenue
{
public String VenueName { get; set; }
public List<EventInstance> Dates { get; set; }
}
public class EventInstance
{
public String When { get; set; }
public String Cost { get; set; }
}
class Program
{
static void Main(String[] args)
{
//read the file
List<int> unreadable;
List<Event> events = readFile(@".\SourceData.csv", out unreadable);
//write the file using the normal JSON serializer. Will output just everything as a single line. If the data structure is changed, it will output in the new structure.
string autoOutput;
JavaScriptSerializer serializer = new JavaScriptSerializer();
autoOutput = serializer.Serialize(events);
File.WriteAllText(@".\autoOutput.json", autoOutput);
}
public static List<Event> readFile(string path, out List<int> unreadableLines)
{
//get the contents out of the file
var lines = System.IO.File.ReadLines(path);
// split each line into an array of strings
var csv = lines
.Select(line => line.Split(';'))
.ToArray();
//will hold all events
List<Event> events = new List<Event>();
//will hold the numbers of all lines which were OK
List<int> unreadable = new List<int>();
//read each line, if you want to skip header lines, change the zero
for (int lineCounter = 0; lineCounter < csv.Length; lineCounter++)
{
string[] line = csv[lineCounter];
if (line.Length >= 4)
{
string eventName = line[0];
Event currentEvent;
//if we haven't yet created the event, create it now and add it to the dictionary
if (!events.Select(ev => ev.Name).Contains(eventName))
{
currentEvent = new Event { Name = eventName };
//the venues of the new event are still empty
currentEvent.venues = new List<EventInVenue>();
events.Add(currentEvent);
}
else currentEvent = events.Where(ev => ev.Name == eventName).Single();
// the same as above: we have the event now, if the current venue isn't yet on its list, enter it, else use the old one
string venueName = line[1];
EventInVenue currentVenue;
if (!currentEvent.venues.Select(ven => ven.VenueName).Contains(venueName))
{
currentVenue = new EventInVenue { VenueName = venueName };
currentVenue.Dates = new List<EventInstance>();
currentEvent.venues.Add(currentVenue);
}
else currentVenue = currentEvent.venues.Where(ven => ven.VenueName == venueName).Single();
string date = line[2];
string cost = line[3];
EventInstance currentEventInstance = new EventInstance { When = date, Cost = cost };
currentVenue.Dates.Add(currentEventInstance);
}
else
//if the line was too short
unreadable.Add(lineCounter + 1);
}
unreadableLines = unreadable;
return events;
}
}
}
... – ElendilTheTall
어느 특별히 의미합니까? – ivoszz
Chrome에서는 XMLHttpRequest가 file : /// C : /data.json을로드 할 수 없습니다. Origin null은 Access-Control-Allow-Origin에 의해 허용되지 않습니다. – ElendilTheTall